stop code sending cancelled email

G

Guest

I am sending an email from the statement
DoCmd.SendObject acSendNoObject, "", acFormatTXT, strTo, , , strSubject,
strBody & strTemplate
This is great as it opens up the email for editing. But if i click the x
(close button) on the email with the intention of sending it to the drafts
folder before sending, it gives an error "The send action was cancelled" and
if i just end it goes to the outbox anyway. Is there any way i can stop the
email sending if i change my mind at the last minute

Thanks
 
A

Allen Browne

Add error-handling to the procedure that contains this line, and trap error
2501.

Example:

Private Sub Command5_Click()
On Error GoTo Err_Handler

DoCmd.SendObject ...

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & ":" & Err.Description
End If
Resume Exit_Handler
End Sub
 
G

Guest

Oops, sorry thought the error handling was working but it seems not. It looks
as though as soon as it goes to the satement

DoCmd.SendObject acSendNoObject, "", acFormatTXT, strTo, , , strSubject,
strBody & strTemplate

it locks itself. I cant navigate away from the email window and it also
seems at that point to have put the email in the outbox.
I am using a procedure from
'A procedure to send report in a body of mail message
'Alex Dybenko, http://Alex.Dybenko.com
as i need to convert the access report to email body text but cant see that
that is having any effect.

Any suggestions please

Thanks
 
A

Alex Dybenko

Hi,
will it work, if you click on send button, instead of x button on email
message?
 
G

Guest

yes the send button works fine. in fact i think it does an immediate send
rather than wait for the schedule but it certainly goes. I am puzzled as to
why the x button does not just put it into drafts
 
A

Allen Browne

From Access' point of view, SendObject either succeeds (the email goes) or
fails (it did not go.)

If you want to save if for later, try hitting the Save button in your email
program. This should save it somewhere (inbox or drafts or something.) Then
close the email without sending (your X button.) The cancel triggers error
2501 in Access, which you can trap and ignore. But if you saved it before
cancelling, it should still be available in your email software later.
 
G

Guest

thanks for your help. as you say it either goes or doesnt. i tried the save
but still have to click x to exit as the screen seems to be locked and at
that stage it goes! Will just have to impress on my users that send means
send. Is there a reason why it locks the message screen

Thanks
 
G

Guest

I have a problem, not email related, but related to the "Save Action
Cancelled" when I open up one form through a button and when I close one form
through a close button. There is no Event Procedures on the opening or
loading of the forms. There are no "DoCmd.save" on any event procedures. Anuy
 
D

Dirk Goldgar

Clois Beckwith said:
Kevin, can you clarify what I can't do in Access 2003, I am confused.

Please ignore "Kevin's" message. He's posting the same completely bogus
message in reply to many different newsgroup questions, apparently in a
fit of pique.

There is no Access 20004, or even 2004, and the link is to a completely
irrelevant page.
 

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

Top