Access - Outlook Mail Automation: SendUsingAccount

L

LeeTV

Hello,
I'm trying to send (from within access) an email that uses a specific account.
I googled around and found the following code: but i cant figure out how to
actually make it work from access.

The purpose of me using this function is that when i am registering clients,
they get a confirmation email from (e-mail address removed), and a bill from (e-mail address removed)
(each of these account is set up in outlook; currently all the email sits in
the outbox in outlook and i have to physcially change them all to the correct
"Send from account". (its not efficient as there can be 20-30 pending emails
at one time that need changing). I tried the "Send on behalf of" feature, but
that still sends it from my default account, but with an "sent on behalf of
email address".

Private Sub SendUsingAccount_Click()
Dim oAccount As outlook.Account

oAccount = "(e-mail address removed)"

For Each objNameSpace In Application.Session.Accounts
If oAccount.AccountType = olPop3 Then
Dim oMail As outlook.MailItem
Set oMail = Application.CreateItem(olMailItem)
oMail.Subject = "Sent using POP3 Account"
oMail.Recipients.Add ("(e-mail address removed)")
oMail.Recipients.ResolveAll
oMail.SendUsingAccount = oAccount
oMail.Send
End If
Next
End Sub


Any help would be most appreciate.
Thanks
LeeTV
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top