I have VBA code that sends Outlook emails via Access.
I cannot send the emails from my secondary (non-default) Outlook account.
To employ the SendUsingAccount property, I am using Minty's code from https://www.access-programmers.co.uk/forums/threads/sendusingaccount-is-not-working.299542/.
When I run the test below, a value of 1 is returned. It counts my personal/default account, but not my secondary one.
I know that I have access to the secondary account, because I can manually send from that account via the "From" dropdown in the message window.
Function Count_Accounts()
Dim OutApp As Object
Set OutApp = CreateObject("Outlook.Application")
Debug.Print OutApp.Session.Accounts.Count
End Function
If I could get the test above to return a value of 2, I believe I'd be able to use Minty's code linked above. Currently, Minty's code can only find my personal account.
.SentOnBehalfOfName works for me.
I did not test the code from your link, but if everything else is working OK, this part of the code should be:
With OutMail
.To = Variable_To
.CC = ""
.BCC = ""
.Subject = Variable_Subject
.SentOnBehalfOfName = 'your@email.whatever'
.Attachments.Add (VarAttachFile)
.HTMLBody = Variable_Body & signature
.Display 'or use .Send
.ReadReceiptRequested = False
End With