Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook: Change sender's From: address

Status
Not open for further replies.

awaresoft

Programmer
Joined
Feb 16, 2002
Messages
373
Location
DE
Is it possible to programmatically change the "From" address used to send an email in Outlook (2000 and higher)?

I have an application that needs to send emails with a specific "From:" email address for the recipient (a computer fax service) to accept the email. Thus we need to temporarily override each users' default From: address when sending these emails.

Normally I would use Blat (YEAH!) but in this case the client is Outlook based and they want all their email to go through their Outlook clients.

I've looked at code on this forum and have found properties for To:, Cc:, Bcc:, Subject:, etc, but no way to customize the senders email address.

Thanks!
Malcolm
 
The closest thing I've found is .SentOnBehalfOfName, but I'm not sure if this requires an Exchange connection or if this property can be used in both standalone Outlook and Exchange connected Outlook.

oOutlook = CreateObject("outlook.application")
oMessage = oOutlook.CreateItem(0)
with oMessage
.SentOnBehalfOfName = "<name@domain.com | "First Last"> ????
endwith

Any issues with using the .SentOnBehalfOfName property?

Thanks,
Malcolm
 
Malcom,

I once had the same problem. I came to the conclusion that there was no way of doing this, because the From address is tied to the account from which the email is being sent. I had to give it up.

I wasn't aware of .SentOnBehalfOfName. I'm not sure what the implications are.

Let us know if you find a solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 

Using CDO 2.0 you can change the sender address and the from address (which are two different things). This requires the CDOsys.dll to be installed and an SMTP service (or server to run).
Code:
oMSG = CREATEOBJECT('cdo.message')
oMSG.To = 'me@nowhere.com'
oMSG.From = 'me'
oMSG.Sender = 'Mike Gagnon'
oMSG.Subject = 'Hello Email'
oMSG.TextBody = 'This is an easy way to create an email'
oMSG.Send()

The above will appear as "Mike Gagnon on behalf of me". Although you don't need to use both sender and From, but you need at least one, and the value of the property can be anything.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike Lewis: Thanks for the thoughts. I'll post back if and when this is resolved. The SentOnBehalfOf sounds promising but in googling this topic I'm not confident that this solution will work in all (or even many) situations

Mike Gagnon: Thanks for the CDO code. My understanding is that CDO will not be installed and configured on the typical user workstation (Windows 2000, XP Pro) and I'm not even sure if its available on XP Home?

My marching orders are "ALL email sent from applications will now go through each user's Outlook email client". (I currently have a great SMTP based system using Blat but my customer's IT department has asked me to shut this solution down and comply with their new "Outloook or nothing" edict.)

I keep telling myself that the "customer is always right" <choke> :)

Thanks again guys for your help,

Malcolm


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top