send mail in Outlook specify sending account

I have an exe which sends mails out from Outlook(2003) and VB>net 2005
I see there is a property SendUsingAccount.
i would like to specify when sending mail which account it must use to send the mail out on.
Does anyone have a simple sample please

Who is Participating?

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

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.

David LeeCommented:
Hi, CraigLazar.

SendUsingAccount isn't available in Outlook 2003.  It was introduced in Outlook 2007.  With Outlook 2003 the way to send through an account is to simulate clicking on the buttons in the interface.

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
CraigLazarAuthor Commented:
Hi BlueDevilFan
ok do u have a sample if i then used Outlook 2007 instead then?
David LeeCommented:
This example is directly from Outlook's online help.
Sub SendUsingAccount()
    Dim oAccount As Outlook.account
    For Each oAccount 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 ("")
            oMail.SendUsingAccount = oAccount
        End If
End Sub

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

CraigLazarAuthor Commented:
one of my accounts isseup usin exchange server, will this still work then?
David LeeCommented:
The code shows sending a message via a POP account.  It's just an example though.  You can use any account you want.  The key point is to select the account you want to use, then set SendUsingAccount to that account object.  You can select the account by name, by type, etc.
I use the From property of the MailMessage through Interop to send email through a different address. For any of these techniques to work, the user whose credentials are being used to send the message (in my case its logged in user) must have SendAs permission on the Exchange Server for the other user.
CraigLazarAuthor Commented:
Hi guys
thank for the help.
I landed up using the .net mailer to send out the mail much easier.
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
.NET Programming

From novice to tech pro — start learning today.