Access - Outlook Mail Automation: SendUsingAccount

  • Follow


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 xxx@yyy.com, and a bill from yyy@xxx.com 
(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 = "xxx@yyy.com"
   
   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 ("leetv@yyy.net")
           oMail.Recipients.ResolveAll
           oMail.SendUsingAccount = oAccount
           oMail.Send
       End If
   Next
End Sub


Any help would be most appreciate.
Thanks
LeeTV
0
Reply Utf 4/19/2010 12:43:01 PM

See my post to Boon (about 3 post up from this one).

Mark

"LeeTV" <LeeTV@discussions.microsoft.com> wrote in message 
news:C4372F5A-DBEE-4834-9E6A-CB1E3825DFC8@microsoft.com...
> 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 xxx@yyy.com, and a bill from 
> yyy@xxx.com
> (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 = "xxx@yyy.com"
>
>   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 ("leetv@yyy.net")
>           oMail.Recipients.ResolveAll
>           oMail.SendUsingAccount = oAccount
>           oMail.Send
>       End If
>   Next
> End Sub
>
>
> Any help would be most appreciate.
> Thanks
> LeeTV 

0
Reply Mark 4/19/2010 7:04:46 PM


1 Replies
1391 Views

(page loaded in 0.032 seconds)


Reply: