• Subject: SendUsingAccount
  • Author: JSOBERWE
  • Date: 17 Feb 2010
  • References:
I am having the same trouble with this. What I am trying to do is use the
.SendUsingAccount property to send an e-mail from an Excel module using a
non-default Outlook account. Environment is:
• Vista Ultimate 64-bit
• Office 2010 Beta 64-bit
• E-mail setup is Exchange, NOT POP3 or SMTP
• E-mail is setup so my profile has full access to the mailbox
“AutoReports”. For clarity, it's added under Account Setting>Change>More
Settings>Advanced
• The code is going in an Excel VBA module.

There is a lot of code in the spreadsheet doing a bunch of different things,
and this code is just test code to get this one feature to work properly.
I’ll integrate it once I get it successfully tested. I suspect something is
just plain wrong in the highlighted area, but I can’t figure out what.

Here's the code:

Sub test()
Set rng = Sheets("SharedRepIDs").Range("A1:L7")

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

Dim OutAcct As Outlook.Account
Set OutNS = OutApp.GetNamespace("MAPI")
OutNS.Logon
Set OutAcct = OutNS.Accounts.Item("sendingaccount@domain.com")

'On Error Resume Next
With OutMail
.SendUsingAccount = OutAcct
.To = "toaccount@domain.com"

.Subject = "Test"
.HTMLBody = "Test"
.Send
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Does anyone know why I may be doing wrong? I can't get the SendUsingAccount
to work! Ugh!
17 Feb 2010SendUsingAccount.JSOBERWE
17 Feb 2010\ Re: SendUsingAccount.Michael Bauer [MVP - ...
17 Feb 2010   \ Re: SendUsingAccount.JSOBERWE
18 Feb 2010      \ Re: SendUsingAccount.Michael Bauer [MVP - ...
18 Feb 2010         \ Re: SendUsingAccount.JSOBERWE
18 Feb 2010            \ Re: SendUsingAccount.Graham Mayor
18 Feb 2010               \ Re: SendUsingAccount.Ken Slovak - [MVP - O...
18 Feb 2010                  |- Re: SendUsingAccount.JSOBERWE
18 Feb 2010                  |  |- Re: SendUsingAccount.JSOBERWE
18 Feb 2010                  |  |  \ Re: SendUsingAccount.Ken Slovak - [MVP - O...
18 Feb 2010                  |  \ Re: SendUsingAccount.JSOBERWE
18 Feb 2010                  |     |- Re: SendUsingAccount.Michael Bauer [MVP - ...
18 Feb 2010                  |     \ Re: SendUsingAccount.JSOBERWE
18 Feb 2010                  |        \ Re: SendUsingAccount.JSOBERWE
18 Feb 2010                  \ Re: SendUsingAccount.Michael Bauer [MVP - ...
18 Feb 2010                     \ Re: SendUsingAccount.Dmitry Streblechenko
19 Feb 2010                        \ Re: SendUsingAccount.Michael Bauer [MVP - ...
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)