Option Explicit
Const SMTP_SERVER As String = "mail.mydomain.com"
Const SMTP_PORT As Long = 25
Const MAIL_SUBJECT As String = "Message from Business Manager User."
Private objMessage As CDO.Message
Private Sub Form_Load()
ConfigureForm Me
End Sub
Private Sub cmdClose_Click()
If MsgBox("You are about to close this screen." & vbNewLine & _
"Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
Unload Me
Else 'vbno
'do nothing
End If
End Sub
Private Sub cmdReset_Click()
If MsgBox("You are about to reset this screen." & vbNewLine & _
"Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
txtEmailAddress.Text = vbNullString
txtMessage.Text = vbNullString
txtEmailAddress.SetFocus
Else 'vbNo
'do nothing
End If
End Sub
Private Sub cmdSend_Click()
On Error GoTo Err
Set objMessage = New CDO.Message
With objMessage
.Subject = MAIL_SUBJECT
.From = txtEmailAddress.Text
.To = MAIL_TO
.TextBody = txtMessage.Text
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_SERVER
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTP_PORT
.Configuration.Fields.Update
.Send
End With
Set objMessage = Nothing
If MsgBox("Your message to the authors was" & vbNewLine & _
"successfully sent.", vbInformation, "Email Message Sent.") = vbOK Then
Unload Me
End If
Exit Sub
Err:
If MsgBox("Your message to the authors could" & vbNewLine & _
"not be sent. Please try again later.", vbCritical, "Email Message Not Sent.") = vbOK Then
Unload Me
End If
End Sub