Changing CurrentUser Programmatically

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?
 
S

Sue Mosher [MVP-Outlook]

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?
 
A

Alan Cuthbertson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top