Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send mails in outlook using differrent account

Posted on 2011-09-19
3
Medium Priority
?
773 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

783 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