Link to home
Start Free TrialLog in
Avatar of darls15
darls15

asked on

Opening and populating a draft Outlook email from Access without sending

Hi Experts

I need some code that will, when attached to a button, open up a new email in Outlook in draft form only.

I would like to be able to hard-code the "From" and "To" email addresses and the "Subject" and "Body" as well.

I don't want to send the email until the user clicks the send button in Outlook - so they can view/change the email if they need.

The intended users could be using various versions of Outlook and Access.

Any help would be appreciated.

Thanks
darls15
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try customize this:

Sub Button1_Click()
    Call OutlookNewMail
End Sub

Sub OutlookNewMail()
    'Remember to add the references: Microsoft Outlook Object Library from menu Tools > References
    Dim o As Outlook.Application
    Dim m As Outlook.MailItem
    Set o = New Outlook.Application
    
    Set m = o.CreateItem(olMailItem)
    m.Subject = "Your Subject"
    m.BodyFormat = olFormatHTML 'Or change it accordingly
    m.Body = "This is the body"
    m.SentOnBehalfOfName = "Sender Name <yourreceiver@there.com>"
    m.Recipients.Add "Receiver Name <yourreceiver@there.com>"
    m.Display
    
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of darls15
darls15

ASKER

Thank you Ryan, this is just what I needed and works perfectly :)
darls15