Results 1 to 22 of 22

Thread: CDO (do not receive email)

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    CDO (do not receive email)

    Hi guys,
    I am looking to use CDO to send a message through my SMTP server. I get the messagebox saying the email has been sent but I never get the email. This is the code I am using:
    VB Code:
    1. Option Explicit
    2.  
    3. Const SMTP_SERVER   As String = "mail.mydomain.com"
    4. Const SMTP_PORT     As Long = 25
    5. Const MAIL_SUBJECT  As String = "Message from Business Manager User."
    6. Const MAIL_TO       As String = "[email protected]"
    7.  
    8. Private objMessage  As CDO.Message
    9.  
    10. Private Sub Form_Load()
    11.     ConfigureForm Me
    12. End Sub
    13.  
    14. Private Sub cmdClose_Click()
    15.     If MsgBox("You are about to close this screen." & vbNewLine & _
    16.               "Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
    17.              
    18.         Unload Me
    19.     Else 'vbno
    20.         'do nothing
    21.     End If
    22. End Sub
    23.  
    24. Private Sub cmdReset_Click()
    25.     If MsgBox("You are about to reset this screen." & vbNewLine & _
    26.               "Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
    27.              
    28.         txtEmailAddress.Text = vbNullString
    29.         txtMessage.Text = vbNullString
    30.         txtEmailAddress.SetFocus
    31.     Else 'vbNo
    32.         'do nothing
    33.     End If
    34. End Sub
    35.  
    36. Private Sub cmdSend_Click()
    37.     On Error GoTo Err
    38.    
    39.     Set objMessage = New CDO.Message
    40.    
    41.     With objMessage
    42.         .Subject = MAIL_SUBJECT
    43.         .From = txtEmailAddress.Text
    44.         .To = MAIL_TO
    45.         .TextBody = txtMessage.Text
    46.         .Configuration.Fields.Item _
    47.         ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    48.         .Configuration.Fields.Item _
    49.         ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_SERVER
    50.         .Configuration.Fields.Item _
    51.         ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTP_PORT
    52.         .Configuration.Fields.Update
    53.         .Send
    54.     End With
    55.    
    56.     Set objMessage = Nothing
    57.    
    58.     If MsgBox("Your message to the authors was" & vbNewLine & _
    59.               "successfully sent.", vbInformation, "Email Message Sent.") = vbOK Then
    60.                  
    61.             Unload Me
    62.     End If
    63.        
    64.     Exit Sub
    65. Err:
    66.         If MsgBox("Your message to the authors could" & vbNewLine & _
    67.                   "not be sent.  Please try again later.", vbCritical, "Email Message Not Sent.") = vbOK Then
    68.                  
    69.             Unload Me
    70.         End If
    71. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width