[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 783
  • Last Modified:

Send mails in outlook using differrent account

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
winman_soft
Asked:
winman_soft
  • 2
1 Solution
 
DavidT543Commented:
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
 
winman_softAuthor Commented:
thank u for replying ..
It worked for me using this :  .SendUsingAccount = OutlookNamespace.Accounts("OtherAccountName")
0
 
winman_softAuthor Commented:
I found the answer  .SendUsingAccount = OutlookNamespace.Accounts("OtherAccountName")
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now