Skip to content

Instantly share code, notes, and snippets.

@chadmando
Created March 9, 2020 21:26
Show Gist options
  • Save chadmando/4dcedc45a65e35e59bd8826f754cda5b to your computer and use it in GitHub Desktop.
Save chadmando/4dcedc45a65e35e59bd8826f754cda5b to your computer and use it in GitHub Desktop.
Create a new Outlook mail message using VBA
Option Explicit
Public Sub CreateEmail(ByVal strSubject As String, ByVal strBody As String, ByVal strRecipient As String)
Dim obApp As Object
Dim NewMail As Variant
'initialize Outlook objects
Set obApp = CreateObject("Outlook.Application")
Set NewMail = obApp.CreateItem(olMailItem)
With NewMail
.Subject = strSubject
.To = strRecipient
.Body = strBody
'.Attachments.Add ("")
.Importance = olImportanceHigh
.Display
End With
' clean up Outlook objects
Set obApp = Nothing
Set NewMail = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment