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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send E-mail to an Address in a Field

Status
Not open for further replies.

RickTX

IS-IT--Management
Oct 16, 2001
3
0
0
US
I have a field for e-mail addresses - I want to automate a form so that when I double click on the e-mail address (or on a command button) it opens Outlook and puts the address in the To: section of the message.
 
Try this:

Code:
Public Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
'Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
        'Add the To recipient(s) to the message.
        Set objOutlookRecip = .Recipients.Add
(YourVariable)
Code:
        objOutlookRecip.Type = olTo
         .Subject = "This an Automation test with Microsoft Outlook, VBA and Access"
        .BODY = "Please RSVP at your convenience            
        .Importance = olImportanceHigh 'High importance
        'Add attachments to the message.
        If Not IsMissing(AttachmentPath) Then
            Set objOutlookAttach = .Attachments.Add(AttachmentPath)
        End If
        'Resolve each Recipient's name.
        'For Each objOutlookRecip In .Recipients
        'objOutlookRecip.Resolve
        'Next
        'Should we display the message before sending?
        If DisplayMsg Then
            .Display
        Else
            .Save
            .Send
        End If
    End With
    rst.MoveNext
Loop
Set objOutlook = Nothing
End Sub
Tyrone Lumley
augerinn@gte.net
 
If Outlook is your default EMail client then all you need is:

DoCmd.SendObject , , , Me!EMail

where EMail is the field name where the Email address is displayed. The underlying table should have the Email address in a hyperlink field.

Uncle Jack
 
Thank Uncle Jack - Works like a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top