0
votes

VBA created emails are sent successfully, however I can only send from the email address of the default account.

As I have a few Office 365 connected email addresses, in Outlook 2016 I am able to manually select the 'FROM' out of the list of available connected email addresses.

In Outlook VBA, there is only one account (the exchange of Office 365), so using SendUsingAccount will find the one account.

SentOnBehalfOfName bounces on security issues. Is it possible to define the 'FROM' email address?

1

1 Answers

0
votes

Yes, you can, but you need to create the different accounts in Outlook. When done, use this code excerpt:

Dim SendAccount As String
SendAccount = "MyDesiredAccountName"

Set MAPISession = objOutlook.Application.Session 
Set MAPIMailItem = objOutlook.CreateItem(olMailItem)  'Create a new mail message

'**********************************************
'* Find desired from-account
'* If not found, use default
'*
For Each Account In MAPISession.Accounts
  If Account = SendAccount Then
    MAPIMailItem.SendUsingAccount = Account
    Exit For
  End If
Next

Is this enough to get you started?