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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to trap error if user cancel email after using .Display

Status
Not open for further replies.

saigonvietnam

Programmer
Dec 6, 2004
9
0
0
US
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
 
Hi, not sure if this is what you are after but:

intSeeOutlook = MsgBox("Preview e-mail message?", _
vbYesNo, Me.cboCaseName & Me.Caption)


Select Case IntSeeOutlook

Case is = vbYes

myItem.Display

Case is = VbNo

…Do something else

MsgBox “Ok, not showing email”

End Select

DoCmd.GoToRecord , , acNewRec
 
Thanks dRahme for replying. Let me explain in the different way:

At: (User choose to preview message before sending)
Case is = vbYes
myItem.Display
After the myItem email has been opened, the user hit the "X" button to close. The email was not sent. How can I detect that the email wasn't sent so I will not update the record using following:

Me.Undo
MsgBox ("Your Mail has been canceled!").

Thanks again!





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top