Hello,
I've previously written Access VBA to send an email through Outlook. I'm now on an exchange server, and I can't figure out how to get my Access VBA to recognize my multiple mailbox accounts within Exchange, and set the account I'd like the emails to be sent from.
Here's what I've tried:
Code:
Dim olApp As Outlook.Application
Dim olOutlookMsg As Outlook.MailItem
Dim olAccount As Outlook.Account
For Each olAccount In Outlook.Application.Session.Accounts
If olAccount = "PMA@cthol.net" Then
Set olApp = GetObject(, "Outlook.Application")
'Create the message.
Set olOutlookMsg = olApp.CreateItem(olMailItem)
With olOutlookMsg
.To = strEmailAddress
.SendUsingAccount = olAccount
.Subject = "Details"
.HTMLBody = strBody
.Send 'Go ahead and send right away
End With
End If
Next
Set olOutlookMsg = Nothing
Set olApp = Nothing
Set olAccount = Nothing
The code above produces no error message. When I execute the code, the for next loop starts with my personal account "gc@cthol.net", goes to the next record, which displays "Live Meeting Transport", then it exits the for next loop.
I've looked into using either the "Store" or "Stores" object(s), but I can't figure anything out.
Thank you in advance!!