outlook-create-a-new-email-message

Outlook - Create A New Email Message

This macro creates a simple text email message.

Outlook

  • 10522
  • 1686
  • 0
  • 0
Add to collection
© 2024VBAmacros.net

1 Open MS Outlook.


2 Go to Developer's tab > click on "Visual Basic" button or hit Alt + F11.


3 Go to Insert tab > click on "Module" or hit M.


4 Copy the VBA code from below.

5 Paste the code in the newly created module.


6 Go to Run tab > click on "Run Sub/UserForm" or hit F5.


7 That's it!

Advertisement

Code
'==========================================
' Create A New Email Message
'==========================================
Public Sub createNewEmailMessage()
    ' Set variables
    Dim objMessage As MailItem
    ' Create new mail item
    Set objMessage = Application.CreateItem(olMailItem)
    ' Use the newly created mail item
    With objMessage
        ' Set recipient
        .To = "test@vbamacros.net"
        ' Set copy recipient
        .CC = "test@vbamacros.net"
        ' Set email subject
        .Subject = "This is the test subject"
        ' Set message format
        .BodyFormat = olFormatPlain
        ' Set message body
        .Body = "This is the test message"
        ' Display the message before sending it
        .Display
    End With
    ' Release the mail item
    Set objMessage = Nothing
End Sub
Advertisement


Comments
Sort by:
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
VBAmacros.net VBAmacros.net
Code was successfully copied!
VBAmacros.net VBAmacros.net
Please sign in!
VBAmacros.net VBAmacros.net
You've already voted!