saigonvietnam
Programmer
Hi! I'm using Access 2003 to send email through a form. User have an option to choose whether or not if he/she want to review the message (made any changes if desired) before sending the message. Since I have to record if the email is actually sent or not, After using the .Display then later the user decide to cancel the mail. Is there a way (or different approach) to detect that error in Access after user's email cancelation? I know using .Send method does allow us to detect such error. Here is the code:
Private Sub cmdSendMail_Click()
On Error GoTo Err_Mail_Cancel
Dim intSeeOutlook As Integer
Set myolApp = CreateObject("Outlook.Application")
Set myItem = myolApp.CreateItem(olMailItem)
myItem.To = Me.txtAttorneyEmail
myItem.Subject = Me.cboCaseName
myItem.Body = "This will be the default Message"
intSeeOutlook = MsgBox("Preview e-mail message?", _
vbYesNo, Me.cboCaseName & Me.Caption)
If intSeeOutlook = vbYes Then
myItem.Display
Else
myItem.Display
SendKeys "%{s}", True
End If
DoCmd.GoToRecord , , acNewRec
Exit_cmdSubmit_Click:
Exit Sub
Err_Mail_Cancel:
Me.Undo
MsgBox ("Your Mail has been canceled!")
End Sub
Private Sub cmdSendMail_Click()
On Error GoTo Err_Mail_Cancel
Dim intSeeOutlook As Integer
Set myolApp = CreateObject("Outlook.Application")
Set myItem = myolApp.CreateItem(olMailItem)
myItem.To = Me.txtAttorneyEmail
myItem.Subject = Me.cboCaseName
myItem.Body = "This will be the default Message"
intSeeOutlook = MsgBox("Preview e-mail message?", _
vbYesNo, Me.cboCaseName & Me.Caption)
If intSeeOutlook = vbYes Then
myItem.Display
Else
myItem.Display
SendKeys "%{s}", True
End If
DoCmd.GoToRecord , , acNewRec
Exit_cmdSubmit_Click:
Exit Sub
Err_Mail_Cancel:
Me.Undo
MsgBox ("Your Mail has been canceled!")
End Sub