Solved

Send mails in outlook using differrent account

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now