Kapusta
asked on
VBA code to choose mail account
I want to be able to have my VBA choose an Outlook 2000 mail account for sending emails. The following code will send an email programmatically from within Outlook 2000:
Set objMail = Application.CreateItem(olM ailItem)
With objMail
' By default person will be added
' to the To area
.Recipients.Add (EmailAddress)
.Subject = SubjectText
.Body = TheBody
' Send it
objMail.Send
Set objMail = Nothing
End With
But this code does not allow me to choose the mail account or specify the "Reply to" or "Sender" values. I need to have control over these parameters.
Set objMail = Application.CreateItem(olM
With objMail
' By default person will be added
' to the To area
.Recipients.Add (EmailAddress)
.Subject = SubjectText
.Body = TheBody
' Send it
objMail.Send
Set objMail = Nothing
End With
But this code does not allow me to choose the mail account or specify the "Reply to" or "Sender" values. I need to have control over these parameters.
What mode is Outlook configured in?
ASKER
>> What mode is Outlook configured in?
Internet POP/SMTP only. We do not use Exchange. Is that what you wanted to know?
Internet POP/SMTP only. We do not use Exchange. Is that what you wanted to know?
Yep. Gives me something to work with since there isn't anything in the object model to specify account. Going to check to see if there is another way to do this.
I'm not sure about how to add it to your VBA code, but it is user selectable from Options... button or View > Options... in a new message.
Colleen
Colleen
ASKER
>> but it is user selectable from Options..
Yes, I understand. But that does not help me when I am trying to use VBA code and select the corresponding account from within the code.
Yes, I understand. But that does not help me when I am trying to use VBA code and select the corresponding account from within the code.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.