Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Ostrosoft SMTP problem

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
NL
I wonder if anyone here has experience of using the Ostrosoft SMTP component to send mail from Access. I cannot work out how to detect (with the ErrorSMTP event?) if my message has successfully been sent or not. Any suggestions?
 
I have seen a number of posts that say "use vbsendmail, it's great"... I have read the documentation, but have not been able to do any kind of error trapping (e.g. "sent successfully," )or any other kind of error message that might go along with it.

Can you post some more specifics on code used and how you utilize the dll?



----------
Jeff Wigal
jeff@wigaldesign.com
Referee Assistant for MS Access
 
Hello,

This is the code I use to show an error (in addition to a general error trap routine):

Private Sub poSendMail_SendFailed(Explanation As String)
DoCmd.Hourglass False
MsgBox ("The Email Failed: " & Explanation & "." & Chr$(160) & Chr$(160) & Chr$(160) & Chr$(160) & Chr$(160)), vbCritical, "Email Status Report:"
Me.Form.Caption = "Edit Invoice"
Me.Form.SetFocus
End Sub

Garry
 
OK, tried that, but it doesn't seem to be trapping for an error. Here's what I have for code

Code:
Option Compare Database
Option Explicit
Private poSendMail As vbSendMail.clsSendMail

Function EMailAssignmentsToReferees(Header As String, Footer As String) As Boolean



Dim rstRefs As Recordset
Dim rightnow As Date

On Error GoTo HandleErr
Set rstRefs = CurrentDb.OpenRecordset("SELECT * FROM Referees WHERE ID IN (Select RefID FROM Assignments);")

Set poSendMail = New clsSendMail

While Not rstRefs.EOF

    poSendMail.SMTPHost = "lgaoiwnngss.com"
    poSendMail.from = "jeff@wigaldesign.com"
    poSendMail.FromDisplayName = "Your Soccer Assignor"
    poSendMail.Recipient = rstRefs!EMail
    poSendMail.RecipientDisplayName = rstRefs!FirstName & " " & rstRefs!LastName
    'poSendMail.ReplyToAddress = txtFrom.Text
    poSendMail.Subject = "Game Assignments for " & rstRefs!FirstName & " " & rstRefs!LastName
    'poSendMail.Attachment = txtFileName.Text 'attached file name
    poSendMail.message = Header & vbCrLf & "-------------------------------" & vbCrLf & vbCrLf
    poSendMail.message = poSendMail.message & EMailDisplayGameInfo(rstRefs!ID)
    poSendMail.message = poSendMail.message & vbCrLf & vbCrLf & "-------------------------------" & vbCrLf & Footer
    poSendMail.message = poSendMail.message & vbCrLf & "-------------------------------"
    poSendMail.message = poSendMail.message & vbCrLf & "E-Mail message generated by Referee Assistant(tm) Assignor Software"
    poSendMail.message = poSendMail.message & vbCrLf & "[URL unfurl="true"]www.referee-assistant.com"[/URL]
    poSendMail.message = poSendMail.message & vbCrLf & "-------------------------------" & vbCrLf
    poSendMail.Send
    
    
    Debug.Print "Sent " & rstRefs!FirstName & " " & rstRefs!LastName
    rstRefs.MoveNext

Wend


Exit Function




ExitHere:
    Exit Function

HandleErr:
    Select Case Err.Number
        Case Else
            MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "modEMail.EMailAssignmentsToReferees"    'ErrorHandler:$$N=modEMail.EMailAssignmentsToReferees
    End Select
' End Error handling block.
Exit Function

End Function




Private Sub poSendMail_SendFailed(Explanation As String)
   MsgBox "Mail Failed!" & vbCrLf & Explanation
End Sub

I put a garbage SMTP server in, hoping to raise an error, but it just goes through and attempts to send an e-mail to each record.

----------
Jeff Wigal
jeff@wigaldesign.com
Referee Assistant for MS Access
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top