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
darls15Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
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

0
Ryan ChongCommented:
or this if you don't want to add an Object Library from References:

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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darls15Author Commented:
Thank you Ryan, this is just what I needed and works perfectly :)
darls15
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.