Solved

Send mails in outlook using differrent account

Posted on 2011-09-19
3
734 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
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you don't know how to downgrade, my instructions below should be helpful.
Read this checklist to learn more about the 15 things you should never include in an email signature.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

786 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