[AccessD] Email problem. Again

Rocky Smolin rockysmolin at bchacc.com
Tue Mar 2 16:04:08 CST 2010


Oh, I'm not using send object.  I'm trying to implement the vbSendMain that
Dan turned me on to.

r 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Tuesday, March 02, 2010 1:49 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Rocky,
I cannot recall  how all this  started,but have you tried  something like
this.

Function Email()
    Dim strTable As String, strTo As String, strCC As String, strBCC As
String
    Dim strSubject As String, strBody As String
    Dim bPreview As Boolean
    DoCmd.SendObject acSendTable, strTable, acFormatXLS, strTo, strCC,
strBCC, strSubject, strBody, bPreview End Function

 whereby you can set up a dummy table to satisfy the requirments  of  the
docmd.

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: 02 March 2010 20:16
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Apparently I need to "authenticate my outgoing server"  whatever the hell
that means.  

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Tuesday, March 02, 2010 11:42 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Well - that's out of scope for me.  But I bet someone else on this list
knows exactly what it means.

I would try copying that complete error message into a google/bing search
field and see what comes up.

Good to see that the vbSendMail code actually told you what's wrong.

Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Tuesday, March 02, 2010 12:47 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Dan:

533 Sorry, that domain isn't in my list of allowed rcpthosts is the message
I get.


What it means?

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Tuesday, March 02, 2010 10:36 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Hi Rocky,

This is a class so it's done a little differently.

The class name is 'EmailSMTP', and we've set up a public variable to
represent that class - 'ES'.

So you can call a procedure in that class like this:

Call ES.SendEmailsNowSMTP(Me.txtSMTPMailServer, _
    Me.txtSMTPUserName, _
    Me.txtSMTPUserName, _
    Me.txtTestSubject, _
    Me.txtTestTo, _
    Me.txtTestTo, , Me.txtTestMessage, Me.txtTestAttachment)

And I think that should do it.


But there's one more thing - change this procedure as shown here:  
(This was code for my error trapping framework.)

-------------------------------------------------------
Private Sub poSendMail_SendFailed(Explanation As String)

DELETE THIS PERMANENTLY:
    '-- The SMTPEmailFailed procedure is called so that ErrEx will record
the Call Stack and also the value of Explanation
    Call Run("SMTPErrorRaise", 600, "poSendMail_SendFailed", Explanation)

ADD THIS FOR TESTING:
    MsgBox Explanation

End Sub
-------------------------------------------------------

I'll be interested to hear what the problem was that you're having!

Dan


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Tuesday, March 02, 2010 11:31 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Dan:

I put your stuff right into the existing app (plan for success). I put your
code into a class module named EmailSMTP and Public ES As New EmailSMTP into
the module with all the PUBLICs.  And the app does compile. 

Now, I'm trying to call the Send Email sub with 

Dim varReturn As Variant

varReturn = SendEmailsNowSMTP(Me.txtSMTPMailServer, _
    Me.txtSMTPUserName, _
    Me.txtSMTPUserName, _
    Me.txtTestSubject, _
    Me.txtTestTo, _
    Me.txtTestTo, , Me.txtTestMessage, Me.txtTestAttachment)

But I get a Sub or Function not defined with SendEmailsNowSMTP highlighted.

What am I doing wrong?

TIA

Rocky


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Monday, March 01, 2010 5:38 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Hi Rocky,

Sorry - badly worded advice!

What I'd suggest to start with is to get this working in a new mdb.  Then
when you know it will work, just move the class module and standard module
over to your mdb.  Of course for the standard module you could just put 
   
    Public ES As New EmailSMTP

in any standard module.

Because you're setting poSendMail as an object using WithEvents, you must
reference the vbSendMail.dll, which typically you would place in the
System32 folder.  

Hope that's better,
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin
Sent: Monday, March 01, 2010 4:51 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Dan:

If I put that into a class module in a new mdb, how will the app that needs
to send the email 'see' the class module?

"Now put this into a standard module:"  in the new mdb, yes?

Does this have to go into a new mdb or can I put it into the application
that I'm trying to fix?

TIA,

Rocky
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Monday, March 01, 2010 1:35 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Email problem. Again

Rocky,

Open a new mdb and put this into a class module named 'EmailSMTP':
----------------------------------------------------------
' C Copyright ProMation Systems, Inc.
' Module    : EmailSMTP
' Author    : Dan Waters

Option Compare Database
Option Explicit

Private WithEvents poSendMail As vbSendMail.clsSendMail

Private Sub poSendMail_SendFailed(Explanation As String)

    '-- The SMTPEmailFailed procedure is called so that ErrEx will record
the Call Stack and also the value of Explanation
    Call Run("SMTPErrorRaise", 600, "poSendMail_SendFailed", Explanation)

End Sub

'Private Sub poSendMail_Progress(PercentComplete As Long) '
'    Debug.Print "poSendMail_Progress " & PercentComplete
'
'    Exit Sub
'    ErrEx.Bookmark = BOOKMARK_ONERROR
'
'End Sub

'Private Sub poSendMail_SendSuccesful()
'
'    Debug.Print "poSendMail_SendSuccesful "
'
'    Exit Sub
'    ErrEx.Bookmark = BOOKMARK_ONERROR
'
'End Sub

'Private Sub poSendMail_Status(Status As String) '
'    Debug.Print "poSendMail_Status " & Status
'
'    Exit Sub
'    ErrEx.Bookmark = BOOKMARK_ONERROR
'
'End Sub

Public Sub SendEmailsNowSMTP(stgSMTPHost As String, _
    stgSMTPFromDisplayName As String, _
    stgSMTPFromAddress As String, _
    stgSMTPSubject As String, _
    stgSMTPRecipientDisplayName As String, _
    stgSMTPRecipientAddress As String, _
    Optional blnSMTPAsHTML As Boolean, _
    Optional stgSMTPMessage As String, _
    Optional stgSMTPAttachmentList As String, _
    Optional stgSMTPReplyToAddress)
    
    If stgSMTPRecipientDisplayName = "" Or stgSMTPRecipientAddress = "" Or
stgSMTPRecipientAddress = "No Email Address" Then
        Call Run("SMTPErrorRaise", 601, "SendEmailsNowSMTP", "Cannot Send
Email")
        Exit Sub
    End If
    
    Set poSendMail = New vbSendMail.clsSendMail

'    -- Set up email paramaters
    poSendMail.SMTPHost = stgSMTPHost
    poSendMail.RecipientDisplayName = stgSMTPRecipientDisplayName
    poSendMail.Recipient = stgSMTPRecipientAddress
    poSendMail.FromDisplayName = stgSMTPFromDisplayName
    poSendMail.from = stgSMTPFromAddress
    poSendMail.Subject = stgSMTPSubject
    
    If Not IsMissing(blnSMTPAsHTML) Then
        poSendMail.AsHTML = blnSMTPAsHTML
    End If
    If Not IsMissing(stgSMTPMessage) Then
        If stgSMTPMessage <> "" Then
            poSendMail.message = stgSMTPMessage
        End If
    End If
    If Not IsMissing(stgSMTPAttachmentList) Then
        If stgSMTPAttachmentList <> "" Then
            poSendMail.Attachment = stgSMTPAttachmentList
        End If
    End If
    If Not IsMissing(stgSMTPReplyToAddress) Then
        If stgSMTPReplyToAddress <> "" Then
            poSendMail.ReplyToAddress = stgSMTPReplyToAddress
        End If
    End If

    '-- When email is originated from the developer's PC, don't actually
send email
    If Environ("ComputerName") <> "DanWaters" Then
        poSendMail.Connect
        DoEvents
        poSendMail.Send
        DoEvents
        poSendMail.Disconnect
        DoEvents
    End If
    
    Set poSendMail = Nothing

End Sub
----------------------------------------------------------

 
 
Now put this into a standard module:
----------------------------------------------------------
Option Compare Database
Option Explicit

Public ES As New EmailSMTP
----------------------------------------------------------

A nice feature of vbSendMail is that it will give you a report of when and
why an SMTP email failed.  But you need to use 'WithEvents' in a class
module for this to work.

You must register both the vbSendMail.dll file and the mswinsck.ocx file.

If you comment out the .SMTPHost line, vbSendMail will try to find the host
name.  That's OK if there's only one.  But if there's more than one and you
want to use a specific host, then you need that host name.

The instruction manual for vbSendMail is really good.

The only significant thing I see different is that I use the
poSendMail.Connect and .Disconnect commands.  Can't remember if those are
necessary or not.

Good Luck!
Dan

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list