Is possible to use VBA to select an email account for Outlook?

I use VBA to create an email from Excel for Outlook.
Is it possible to create code in VBA to select a specific email account in Outlook?
spar-kleOperations DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub Mail_Change_Account()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    For I = 1 To OutApp.Session.Accounts.Count
        If OutApp.Session.Accounts.Item(I).DisplayName = "name.Surname@yourfirm.com" Then
            Set OutAcc = OutApp.Session.Accounts.Item(I)
            Exit For
        End If
    Next I

    strbody = "Hi all"

    On Error Resume Next
    With OutMail
        .To = "abc@abc.lt"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = strbody
        .SendUsingAccount = OutAcc

        .Send   'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutAcc = Nothing
    Set OutApp = Nothing
End Sub

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ProfessorJimJamMicrosoft Excel ExpertCommented:
this is not a blink link.

this link explains and has the code.

i do not link posting someone else code as copy and paste, so i refer you to the original author post

http://www.rondebruin.nl/win/s1/outlook/account.htm
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.