Sample Outlook Automation

Create Outlook E-Mail Message (From Excel) – Early Binding

Sub CreateMailInExcelEarlyBound()
Dim olApp As Outlook.Application
Dim Msg As Outlook.MailItem

Set olApp = New Outlook.Application

Set Msg = olApp.CreateItem(olMailItem)

Msg.Display

Set Msg = Nothing
Set olApp = Nothing
End Sub

Create Outlook E-Mail Message (From Excel) – Late Binding

Sub CreateMailInExcelLateBound()
Dim olApp As Object
Dim Msg As Object

Set olApp = CreateObject("Outlook.Application")

Set Msg = olApp.CreateItem(0)

Msg.Display

Set Msg = Nothing
Set olApp = Nothing
End Sub

Create Outlook Contact (From Excel) – Early Binding

Sub CreateContactInExcelEarlyBound()
Dim olApp As Outlook.Application
Dim Ctct As Outlook.ContactItem

Set olApp = New Outlook.Application

Set Ctct = olApp.CreateItem(olContactItem)

Ctct.Display

Set Ctct = Nothing
Set olApp = Nothing
End Sub

Create Outlook Contact (From Excel) – Late Binding

Sub CreateContactInExcelLateBound()
Dim olApp As Object
Dim Ctct As Object

Set olApp = CreateObject("Outlook.Application")

Set Ctct = olApp.CreateItem(2)

Ctct.Display

Set Ctct = Nothing
Set olApp = Nothing
End Sub

Create Outlook Task (From Excel) – Early Binding

Sub CreateTaskInExcelEarlyBound()
Dim olApp As Outlook.Application
Dim Tsk As Outlook.TaskItem

Set olApp = New Outlook.Application

Set Tsk = olApp.CreateItem(olTaskItem)

Tsk.Display

Set Tsk = Nothing
Set olApp = Nothing
End Sub

Create Outlook Task (From Excel) – Late Binding

Sub CreateTaskInExcelLateBound()
Dim olApp As Object
Dim Tsk As Object

Set olApp = CreateObject("Outlook.Application")

Set Tsk = olApp.CreateItem(3)

Tsk.Display

Set Tsk = Nothing
Set olApp = Nothing
End Sub

Create Outlook Journal Entry (From Excel) – Early Binding

Sub CreateJournalInExcelEarlyBound()
Dim olApp As Outlook.Application
Dim Jrnl As Outlook.JournalItem

Set olApp = New Outlook.Application

Set Jrnl = olApp.CreateItem(olJournalItem)

Jrnl.Display

Set Jrnl = Nothing
Set olApp = Nothing
End Sub

Create Outlook Journal Entry (From Excel) – Late Binding

Sub CreateJournalInExcelLateBound()
Dim olApp As Object
Dim Jrnl As Object

Set olApp = CreateObject("Outlook.Application")

Set Jrnl = olApp.CreateItem(4)

Jrnl.Display

Set Jrnl = Nothing
Set olApp = Nothing
End Sub

Create Outlook Note (From Excel) – Early Binding

Sub CreateNoteInExcelEarlyBound()
Dim olApp As Outlook.Application
Dim sNote As Outlook.NoteItem

Set olApp = New Outlook.Application

Set sNote = olApp.CreateItem(olNoteItem)

sNote.Display

Set sNote = Nothing
Set olApp = Nothing
End Sub

Create Outlook Note (From Excel) – Late Binding

Sub CreateNoteInExcelLateBound()
Dim olApp As Object
Dim sNote As Object

Set olApp = CreateObject("Outlook.Application")

Set sNote = olApp.CreateItem(5)

sNote.Display

Set sNote = Nothing
Set olApp = Nothing
End Sub

See the Binding page for additional help implementing these samples.

Site last updated: May 17, 2012

Excel School