Created
March 9, 2020 21:26
-
-
Save chadmando/4dcedc45a65e35e59bd8826f754cda5b to your computer and use it in GitHub Desktop.
Create a new Outlook mail message using VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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