Sending email from Access - controling the form after

garyh_uk

New member
Local time
Today, 13:22
Joined
Mar 13, 2012
Messages
3
Hi everyone

I have a form in MS Access 2007 from which I can send an email, this works fine, and I have managed to trap the error code when the user cancels the email, again this works fine.

The problem I am having is that I want the form to close after the user has sent the email or clicked the send email button. When the Outlook window opens, it seems the script then stops unless an error occurs. While I can return the error code to show the email wasnt sent, is there any way for Access to know the email was sent and then close the form?

Thanks
Gary
 
Howzit

Put it as an action on sub exit. Something like the below:

Code:
Private Sub cmdSendEmail_Click()
On error GoTo err_cmdSendEmail_Click

    MsgBox "Hello"

exit_cmdSendEmail_Click:
    DoCmd.Close
    Exit Sub

err_cmdSendEmail_Click:
    MsgBox Err.Description
    Resume exit_cmdSendEmail_Click
    
End Sub
 
Thanks Kiwiman that worked - one more question, I have my own mailbox and a department generic one which I am able to send emails from, is there any way to choose to send them from my department email account rather than my own (which it currently does)?

Thanks
 
Howzit

Sorry - that is a little out of my league as I have never tried this.

You my want to read this for more information
 

Users who are viewing this thread

Back
Top Bottom