Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dbl click email address on form and open outlook

Status
Not open for further replies.

whill1

Technical User
Feb 14, 2004
46
0
0
US
Hello'
I have a contacts form in access, I have a field for the contact's email address. I want to double click on this email address and open outlook to send an email to this contact. I do not need anything fancy like mass mailings or attachments. I know very little about code in Outlook but somewhat familiar with access code. I tried setting up a button as a hyperlink as described in HELP. it opened Outlook fine but defaulted to the email address that it asked for when I created the button. How do I get Outlook to open ready to send an email to the selected address.

If possible I need to do this without having the addresses in the outlook addressbook as I have many email addresses in an existing database.

Thanks to All who may be able to help.
whill1
 
whill1,

I can't take credit for the code below, see the rem'd comments for the author and website. I did modify for your situation. If it doesn't work, please let me know.
Code:
Private Sub txtEmailAddress_DblClick(Cancel As Integer)
'From [URL unfurl="true"]http://www.rondebruin.nl/sendmail.htm[/URL]
'You must add a reference to the Microsoft outlook Library
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim EmailAddress As String
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    Forms(0).txtEmailAddress.SetFocus
    EmailAddress = Forms(0).txtEmailAddress.Text
    With OutMail
        .To = EmailAddress
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "This is the Body of the message"
        .Display   'or when your ready to really email use .Send
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Fred
 
I tried this code and it open microsoft word. How do I open outlook?
 
Make sure you have the Outlook reference file checked. Go to Tools --> Reference Files --> Microsoft Outlook 10.0 Object Library.

-mike
 
And isn't word your mail editor ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
This is the easiest way I have found to send an email:

Application.FollowHyperlink "mailto:" & strLocation, , True

strLocation is the email address (Him@her.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top