Changing CurrentUser Programmatically

  • Thread starter Thread starter Alan Cuthbertson
  • Start date Start date
A

Alan Cuthbertson

Hi,

I have a VB6 program that is sending emails using the Outlook Object Library
in Outlook 2003. It is all working fine except it always uses the Default
User account to send the email.

I can go in to outlook and change the default user then send the email, but
I would rather automate this part.

I am able to create the Outlook session and view the current user via the
mOutlookApp.Session.CurrentUser, but it is only read only. Is there a way to
change it?
 
No, it's read-only. It wouldn't do any good even if you could, because it has
no bearing on how messages are sent.

Can you provide more details? Are you trying to send from another Exchange
mailbox? With through a different POP3/SMTP or IMAP4/SMTP account? Is Word
the email editor?
 
Hi Sue,

I am using Outlook 2003, and they are Pop/SMTP accounts and I am using Word
as the email editor.

The bit of VB6 code I use is :-

Dim mOutlookApp As Outlook.Application
Dim mNameSpace As Outlook.NameSpace
Dim mItem As MailItem

Set mOutlookApp = CreateObject("Outlook.application")
Set mNameSpace = mOutlookApp.GetNamespace("MAPI")

MsgBox mOutlookApp.Session.CurrentUser

Set mItem = mOutlookApp.CreateItem(olMailItem)
mItem.Recipients.add "aaa@bbbb"
mItem.Subject = "test"
mItem.BodyFormat = olFormatHTML
mItem.HTMLBody = "Message"
mItem.Save
mItem.Send
 
Back
Top