• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Email, OutLook when I have to choose the Origin account

drom

New Member
Hi and thanks in advance!
I have a macro that uses OutLook to send attachments, etc through OutLook using Excel VBA.

The macro works fine, does every thing OK except:

If I have 2 or more OutLook accounts , I would like to choose which one I like to use.

At present I am using:

Code:
    With OutMail
      '''.From = wEmailFrom ????
      '.display
      .To = wEmail                  
      .CC = wCC                      
      .BCC = wBCC                  
      .SendUsingAccount = wEmailFrom    'Does NOW WORK
      '.SentOnBehalfOfName = wSentOnBehalfName 'Does NOW WORK
      .Subject = wSubject
      .Body = wTextBody
end with

So I f I have 3 OutLook Accounts say eg:


If I choose:
Don't Know why Outlook always is using:

I mean I am sending the mail, but not using the desired OutLook account.

Any IDEA what am I missing?
what do I need?


PS: I know rondebruin's website

Thanks again!
 
You need to set Outlook.Account

So something like...
Code:
Dim oAcct as Object
Set oAcct = OutMail.Session.Accounts("Your Account Name")

OutMail.SendUsingAccount = oAcct

Now, it will depend on your Outlook version if this can be done. If I recall, won't work for version before 2007.
 
Hi!

I am actually doing that and I have office 2013.

I mean:

Code:
Dim wEmailFrom As String:        wEmailFrom = OutApp.Session.Accounts.Item(xMailAccount)
where xMailAccount = 2
and I get:
wEmailFrom = Account2@Outlook.com
But when I put:

Code:
OutMail.SendUsingAccount = wEmailFrom
I mean:
Code:
OutMail.SendUsingAccount = "Account2@Outlook.com"
I am sending through, "Account1@Outlook.com"

and Don't know why!
 
Hi Solved:

Looks like If I put:
Code:
    With OutMail
      .To = wEmail
      .CC = wCC
      .BCC = wBCC
      Set .SendUsingAccount = OutApp.Session.Accounts.Item(2)
      '.SendUsingAccount = wEmailFrom
      '.SentOnBehalfOfName = wSentOnBehalfName
      .Subject = wSubject
      .Body = wTextBody
      '.display
      .send
    End With

Works!
I mean I get the mail from
Not from : Account1@Outlook.com
 
Back
Top