Full Version: Email from a form
UtterAccess Forums > Microsoft® Access > Access Forms
Rainlover
I have an unbounded control on a form which displays a customer's email address.
How do I click on this and get my Outlook to open with the To: line displaying that email address?
Should be simple but I can't find the right info here. Could someone please point me in the right direction. Thanks
davej
Try looking up the send mail command, they may give you a start. I have done it using outlook express, but not outlook.
davej
I will try to find a sample bit of code for you.
Rainlover
Thanks Dave
That would be good.
ansentry
1. Put this code behind a command button called cmdSendEmail.
2. Make sure the name of your unbound text box is txtEMail.
CODE

On Error GoTo Err_cmdSendEMail_Click
DoCmd.SendObject acSendNoObject, , , _
    TxtEmail, , , "Your subject text goes here", "Enter your message here ....", True
Exit_cmdSendEMail_Click:
    Exit Sub
Err_cmdSendEMail_Click:
    
    MsgBox "No message was sent", vbInformation, "Your Title"
    Resume Exit_cmdSendEMail_Click
Rainlover
Thank you very much for that. I will give it a go.
GlenKruger
This POST in the code Archieves will give you a good example of emailing from a form. You will have to set the references and object to your version of Outlook.
Rainlover
Thanks Glen
GI_Joe
I have nothing to add. But I do have a question about the code John entered.confused.gif The cmdSendEMail button opens up Outlook just fine, but it opens it in Plain Text. Is it possible to have it open up in HTML or Rich Text?
icah
GlenKruger
You can set the Output Format in the DoCmd.SendObject statement. Type it into a module and it will be the 3rd parameter.
GlenKruger
Your Welcome,
Hope it was of some help.
Rainlover
John, I have used your code and it works great to send a single email. Thanks.
len I looked at your link and it is great for sending the same email to multiple addresses.
Thanks to Dan for his original post.
I have changed Set myOlApp = CreateObject("Outlook.Application.9")
to Set myOlApp = CreateObject("Outlook.Application") which picks up my version of Outlook automatically. I am yet to test this on other computers with differing versions.
What I would like to acheive is to First find the default email program, eg if the person is using Outlook Express, Then subsitute CreateObject("Outlook.Application") with CreateObject("Users Email version.")
Would appreciate help from anyone out there.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.