Solved

Send mails in outlook using differrent account

Posted on 2011-09-19
3
751 Views
Last Modified: 2012-05-12
I have a vb6 code to send mail from my outlook account , but recently i added a new account in outlook.
How to send mail from a different account of Outlook 2010 from VB6?
The new account created is not the default account.
0
Comment
Question by:winman_soft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:DavidT543
ID: 36565262
Hi,

you can use the account object.

My VB6 is a little rusty - I have translated from C# so you may need to adjust the syntax, but you get the picture. (I didn't test the code - but it illustrates the principle)


'* Retrieve the account that has the specific SMTP address. 
Dim MyAccount as Outlook.Account
MyAccount = GetAccountForEmailAddress(application, smtpAddress)

'* Use this account to send the e-mail. 
newMail.SendUsingAccount = MyAccount
newMail.Send()

'*
Sub GetAccountForEmailAddress(application, smtpAddress) as account
Dim Myaccounts as Outlook.Accounts
Myaccounts = application.Session.Accounts
foreach  Myaccount in accounts 
            
  if Myaccount.SmtpAddress = smtpAddress then
     GetAccountForEmailAddress = Myaccount
     exit sub
   end if
end sub

Open in new window

0
 

Accepted Solution

by:
winman_soft earned 0 total points
ID: 36565352
thank u for replying ..
It worked for me using this :  .SendUsingAccount = OutlookNamespace.Accounts("OtherAccountName")
0
 

Author Closing Comment

by:winman_soft
ID: 36591881
I found the answer  .SendUsingAccount = OutlookNamespace.Accounts("OtherAccountName")
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question