We help IT Professionals succeed at work.

Sending email (outlook2000 / vb6) - using MAPI - with secondary email accounts!

algecoadh
algecoadh asked
on
I have multiple email accounts in Outlook 2000 (one of them is set as default).
Using VB6 / MAPI, i want to send email to different recipients using different
accounts - which are configured with different outgoing mail servers (smtp).
How to do this?

If not possible with Mapi,  any other solution???
Thanx
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010

Commented:
Hi, algecoadh.

It is possible to do this with something like the code below.  This is code I've used in Outlook.  Modify it as needed to work in VB.


Set olkSendThroughBtn = Application.ActiveInspector.CommandBars("Standard").Controls(3)
'Replace 2 on the line below with a number corresponding to the position of the account to send through in the list of accounts
Set olkSendAccount = olkSendThroughBtn.Controls(2)
olkSendAccount.Execute

Open in new window

Author

Commented:
Can you pls supply the code which precedes the one you have sent???
Thanx.
CERTIFIED EXPERT
Top Expert 2010
Commented:
Sure, here it is.
Sub CreateNewMessage()
    Dim olkMessage As MailItem, _
        olkSendThroughBtn As Object, _
        olkSendAccount As Object
    Set olkMessage = Application.CreateItem(olMailItem)
    olkMessage.Display
    Set olkSendThroughBtn = Application.ActiveInspector.CommandBars("Standard").Controls(3)
    'Change (2) on the following line to the position in the list of accounts that this account occupies
    Set olkSendAccount = olkSendThroughBtn.Controls(2)
    olkSendAccount.Execute
    Set olkSendAccount = Nothing
    Set olkSendTrhoughBtn = Nothing
End Sub

Open in new window

Author

Commented:
Works like a charm...;-)
Tbanx!

Author

Commented:
Works like a charm ;-)
THANX.
CERTIFIED EXPERT
Top Expert 2010

Commented:
You're welcome.  Glad I could help.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.