View Full Version : Having an error with automated email.


away2play
03-30-2001, 01:30 AM
I've added the following to a form feild named Email so that people can just click on the email address on the for to fire up their default email program with the address, subject and intro text "Dear John" already inputted.

The problem I'm having is that I'm getting a runtime error 2501 when you exit (X) the email without actually sending it. Is there something I need to add to the script below to catch this error without giving an error/debug message everytime as the "you've cancelled your email message" doesn't seem
to work . . .

Thanx in advance.


Private Sub EMail_Click()

DoCmd.SendObject acSendNoObject, ObjectName = stDocName, outputformat:=acFormatRTF, to:=EMail, subject:="RE:", Messagetext:="Dear " &
[ID_FirstName]

Exit_EMail_Click:
Exit Sub

Err_Email_Click:
strMsg = "You have cancelled your Email"
MsgBox strMsg
Resume Exit_EMail_Click

End Sub

KevinM
03-30-2001, 02:53 AM
I don't know if this is the cause of your problem but you have selected acSendNoObject yet passed an objectname and format....
stDocName, outputformat:=acFormatRTF

Remove these if your are not sending an attachment, otherwise select what you are sending.

hth

away2play
03-30-2001, 03:02 AM
Thanx for the fast reply Kev

I'd done as you said but still get a

runtime error 2501
the sendobject action was canceled
end, debug

when closing the mail window without sending the email, this error message is what i'm trying to get rid of

KevinM
03-30-2001, 03:32 AM
Have you set up error trapping?
Looking at your post it does seem to have error trapping BUT no....On Error Goto line at the beginning. Do you have this at the beginning of your routine? This sould trap you error.

away2play
03-30-2001, 03:05 PM
D'oh missed that one . . must have deleted it somewhere along the line http://www.access-programmers.co.uk/ubb/frown.gif

Always the simple things one overlooks.

Thanx again Kev