VBA Outlook - Convert Early Binding to Late Binding
Early Binding
First establish the reference with the outlook library by going to 'Tools' Tab then Click on 'References', from the available reference Select the "Microsoft Outlook 16.0 Object Library", 16.0 could be 14.0 or 15.0 basis on the version of the Microsoft Office in your system.
Dim oApp as Outlook.Application
Dim oEmail as Outlook.MailItem
Dim oNS as Outlook.NameSpace
Set oApp=New Outlook.Application
Set oEmail=oApp.CreateItem(olMailItem)
Set oNS=oApp.GetNamespace("MAPI")
oEmail.SendUsingAccout=oNS.Accounts.Item(1) 'To send email from a specific account.
Late Binding
No need to establish relationship with any library.
Dim oApp as Object
Dim oEmail as Object
Dim oNS as Object
Set oApp=CreateObject("Outlook.Application")
Set oEmail=oApp.CreateItem(0)
Set oNS=oApp.GetNamespace("MAPI")
oEmail.SendUsingAccount=oNS.Accounts.Item(1) 'To send email from a specific account.
Comments
Post a Comment