VBA Outlook - Ways to send email from a specific email account
Early Binding
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") 'Messaging Application Programming Interface
oEmail.SendUsingAccout=oNS.Accounts.Item(1) 'To send email from a specific account.
Or Use
With oEmail
.SentOnBehalfOfName="Enter the specific account email-id."
end With
Late Binding
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") 'Messaging Application Programming Interface
oEmail.SendUsingAccount=oNS.Accounts.Item(1) 'To send email from a specific account.
Or Use
With oEmail
.SentOnBehalfOfName="Enter the specific account email-id."
end With
Comments
Post a Comment