Emailing from Access to Outlook Error

T

TB

I have a field for entering addresses in my database and I would like for a
user to click on the e-mail address in the field and it opens Outlook. I
used the following code for the OnClick Event Procedure:

DoCmd.SendObject acSendNoObject, , , [E-MAIL]

When I click on the e-mail address on my form, it will open Outlook but when
I try to close the message I get a "Run-time error '2501': The SendObject
action was canceled" and Microsoft Visual Basic opens for me to debug the
code. How can correct this?

TB
 
R

rico

You need to add in some error handleing code. Somthing like:

On Error Goto Err_NameOfYourButton_Click

DoCmd.SendObject acSendNoObject, , , [E-MAIL]

Exit_NameOfYourButton_Click:
Exit Sub

Err_NameOfYourButton_Click:


End Sub

Leaving Err_Nameof yourbutton with nothing in it will stop the error message
occuring. For some reason setwarnings off does not work in this case.

HTH

Rico
 
T

TB

It works. THANK YOU!!!!!

rico said:
You need to add in some error handleing code. Somthing like:

On Error Goto Err_NameOfYourButton_Click

DoCmd.SendObject acSendNoObject, , , [E-MAIL]

Exit_NameOfYourButton_Click:
Exit Sub

Err_NameOfYourButton_Click:


End Sub

Leaving Err_Nameof yourbutton with nothing in it will stop the error message
occuring. For some reason setwarnings off does not work in this case.

HTH

Rico


TB said:
I have a field for entering addresses in my database and I would like for a
user to click on the e-mail address in the field and it opens Outlook. I
used the following code for the OnClick Event Procedure:

DoCmd.SendObject acSendNoObject, , , [E-MAIL]

When I click on the e-mail address on my form, it will open Outlook but when
I try to close the message I get a "Run-time error '2501': The SendObject
action was canceled" and Microsoft Visual Basic opens for me to debug the
code. How can correct this?

TB
 
Top