How do i send an Outlook message on the push of a button?

eddyc

Registered User.
Local time
Today, 00:03
Joined
Mar 23, 2011
Messages
43
I want to pull up an outlook send message window, the address having been taken off the access form .... how do i do this. I have looked up code but it looks complicated is it? Also unsure how to call a module once i have written or in my case copied it!!!!! aaaaahhhhh!
 
Have a look at DoCmd.SendObject

If you Simply want to send a message at the click of a button your code in the On Click event might look something like;
Code:
DoCmd.SendObject acSendNoObject, , , "ToEmailAddress", "CCEmailAddress", BCCEmailAddress", "Email Subject", "Email Message Boddy Text", "False"
 
Thank You. That is great but how do i pass it the contents of a field on the form for instance put [Client Email] into the address bar when the window opens?
 
You can use;
Code:
DoCmd.SendObject acSendNoObject, , , Me.ToEmailAddressField, Me.CCEmailAddressField, Me.BCCEmailAddressField, Me.Email SubjectField, Me.[Email Message Boddy Text Field], "False"
 
DoCmd.SendObject acSendNoObject, , , Me![Top of Jobs].Form.Email, , , "Email Subject", "Email Message Boddy Text", "False"

it is saying that "an expression you entered is the wrong type"!?

Email field is a text field maybe it is expecting single paretnheses?
 
Have you had a look in the help files what it says about DoCmd.SendObject?

For starters you haven't specified what to send :confused: The code John gave you was just to get you started.
 
I have built it now itworks until i press the button again! the second time access hangs can anyone tell me why?

Private Sub Command286_Click()
On Error Resume Next
DoCmd.SendObject acSendNoObject, , , Me![Top of Jobs].Form.Email, , , , , True
End Sub

Thank You Ed
 
Have you had a look in the help files what it says about DoCmd.SendObject?

For starters you haven't specified what to send :confused: The code John gave you was just to get you started.

Hi vbaInet, yes i have. Thank you. I have managed to write the code. Currently it is hanging when i press the button a second time. I'm assuming i have to end the On Error Resume Next - any ideas. Will be working on that now!

Cheers and Thank You

Eddy
 
Here is the code with code tags!

Code:
Private Sub Command286_Click()
On Error Resume Next
DoCmd.SendObject acSendNoObject, , , Me![Top of Jobs].Form.Email, , , , , True
End Sub
 
So how do you know that it is working when you've got an error handler that shuts-up the error message?

Remove the On Error Resume Next line and run the code again, then tell us what the error message is. Hardly do you see developers supressing error messages in such fashion.
 
the code works fine. But if i close the email window without sending the it comes up with a sendobject macro halted which i didn't want so i just put a on Error Resume Next ..
ps "Hardly do you see developers supressing error messages in such fashion" - everyone has to start somewhere."
 
Move the code to the Code Builder and you will get a more meaningful error message.
 
Basically it wasn't anything to do with the error handling line the button seems to fail the second time i push it. There is no error message access just hangs! Cheers, hope that helps narrow it down.

ed
 
no it isn't it's just a normal form.

Why would the button hang on second push?

Ed
 
No its not its just a normal form ... seem to have a problem with active x control on another button could that be causing the problem with the email sub?
 

Users who are viewing this thread

Back
Top Bottom