Canceling sendobject

J

Jean-Paul

Hi,

with following code I send an email

SUBJECTBOX = "Mailing 4-parts"
MESSAGEBOX = ""
DoCmd.SendObject , , , "MAILTO:" & Me!Tekst90, , , [SUBJECTBOX],
[MESSAGEBOX], -1

This opens my mail-program and places everything in the correct fields...

So far... perfect

But, when I finally don't want to send the the mail and close the
"mail-send-window" I get an errormessage 2501:
Action SendObject is cancelled

I don't want this errormessage to appear because there was nothing wrong...
How to avoid this?
 
D

Dale Fye

Two ways:

Add an error handler to your code, so that when the error happens, it jumps
to the error handler, where you test for the 2501 error. If it is 2501,
ignore it and Resume; otherwise, display an error message or handle the other
error.

The second way is the same concept, only do it in line. I prefer the first
method, since it will handle all of my errors, and I can code the response
appropriately to the error.

On Error Resume Next
SubjectBox = ...
MessageBox = ...
Docmd.SendObject ,,,,,
If err.number = 0 or err.number = 2501 then
'do nothing
else
msgbox err.number & vbcrlf & err.description, ,_
"Error encountered during sendobject!,
endif
On Error GoTo ErrorHandler

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
J

Jean-Paul

When I do it the second way I get a message saying

On Error GoTo ErrorHandler

compiling error
name is not defined

JP
 
D

Dale Fye

You have to define an Error Handler or use:

On Error Goto 0

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

clicking on a field to send mail 1
code goes too fast 1
SendObject 1
Sendobject 8
more sendobject-problem info 5
Send Object 0
SendObject Action Message 1
can't get sendobject to open email 3

Top