Automatically setting the ‘From’ address of a new Outlook message
Posted by benchristian on December 18, 2005
Setting an alternate reply address is particularly useful if you are using a mail enabled public folder or distribution list for a group of users and would like the replies to messages that they send to go to the group smtp address instead of the sender’s mailbox.
There are a several ways to set the reply address for a new message. The first two methods that I will cover are acheived using a custom form. The other method is to set the address programmatically by using vbscript (or another language).
Custom Form methods:
There are 2 different ways to set the reply address using a custom form; both methods have slightly different results. The first method is to simply populate the ‘from’ field with the address that you’d like replies to be sent to. When using this method, the recipient will clearly see that the message has a different ‘from’ address and, as expected, when they hit reply their mail client will address the message to the ‘from’ address.
The second method is to click on the options button for the new message and enter an address in the “have replies sent to:” field. This method preserves the sender’s name, but sets a different reply address. The recipient will see that the message was sent by the sender, but when they hit reply the mail client will address the message to an alternate address.
With both of these methods you need to compose a new message, set the required options and then publish the item as a custom form. You can then use that custom form when you wish to send a message with the alternate reply address. There is a way that you can programmatically create a new message based a custom form; I promise I’ll post that soon.
Custom forms have their limitations however. For a start, the form needs to be published somewhere first; either in the organisational forms library, personal forms library, or a folder. Forms in the local forms cache are also prone to corruption and custom forms in general can be fiddly. Therefore the custom form method is not my preferred method.
Scripted Method (vbscript)
There are few different ways to make it easy for users to click a button to compose their message with the alternate reply address. You could write some VBA code and assign a toolbar button to it; when the users want to send a message using the alternate reply address they simply click the toolbar button. Another approach is to create an html folder homepage for a folder or public folder. In the html code, you can create a button to run some vbscript code to create the message and set the reply address (see below). The advantage to using a public folder homepage is that you avoid having to copy the VBA code to each workstation and manually creating a toolbar button. You can extend the concept by using the Outlook View Control(OVC) in your HTML homepage so that you have a ‘New Message’ button, and directly below have the contents of the public folder displayed in the OVC. The Outlook View Control is beyond the scope of this entry but because it’s so useful it’s on my list of blog topics!
When I first attempted to set the reply address using vbscript (before I downloaded the object model map!) I was trying to set the reply address using the wrong property. I tried two properties first: the SenderName and SenderEmailAddress properties. When I tried to set these properties with vbscript I would receive an error message stating “property is read-only“. If you refer to the object model you’ll see that these are in fact read-only.
The correct property to assign a reply address is the SentOnBehalfOfName property. I’ll admit that when I first saw this property I didn’t try it straight away as I assumed that it would have been read-only too based on the fact that the name of the property is in past tense (SentOnBehalfOfName). The SentOnBehalfOfName sets the ‘from’ field in the new message, so using this method has the same effect as the first custom form method above.
Here is an example of how create a new outlook mail item with an alternate reply address:
Set OlApp = CreateObject("Outlook.Application")
Set NewMessage = olApp.CreateItem(0)
NewMessage.SentOnBehalfOfName = "test@test.com"
NewMessage.Display
if you are scripting or programming with Outlook 2003, I recommend that you download the Outlook 2003 object model map from the microeye website (http://www.microeye.com/resources/code.htm).
Muhammad AmjaD said
Hi there,
Nice piece of code & working. Thanks.
Classy man winter boot said
James Purnell’s new Renaissance is
It’s just that – bless their self-effacing boots – they’re hiding behind Sarah Lucas. Mind you, this new Renaissance
Kalibo Wrath said
Excellent article!
This code is just what I needed, thanks dude!
Cetoken said
This is great, and worked like a charm – thanks! But (of course there’s a “but”)…
I send a lot of Word docs using the File > Send to Mail Recipient (As attachment) option. Do you have a way to make the resultant message automatically populate “From” with an alternate address? It would be a huge help for me!
Thanks!
Random said
I’m looking for something that will automatically change the from address when replying to message from a particular domain. Clicking a button doesnt save time and you still have to remember to do it.
benchristian said
You’re probably best to use a custom form, although it would be a bit fiddly. The idea is that you would write some vbscript code to set the reply address if it the sender address is from a particular domain.
Tasha said
I get an error: “You do not have the permission to send the message on behalf of the specified user”
Ben Christian said
Hi Tasha, you need to make sure that you have Send As rights on the mailbos that you’re trying to use as the reply address
sandrar said
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
Wemyrpwn said
Could you please repeat that? lolita top sites
tfb
Foptvpdp said
A pension scheme underage pics
508
pratikbijal said
This was simple and fantastic. i struggled for a solution and got it here…thanks
Nuceqald said
Punk not dead Teen Nymphet Pussy 8-]]
Mhzzhjpk said
Will I be paid weekly or monthly? Preteen Glamour Models Toplist >:D
Kvylfrib said
I’m only getting an answering machine Loli Dorki Pthc
=[[[
Buctjifn said
Yes, I play the guitar Mini Models Nn
9070
Adharpdp said
I can’t get through at the moment Cooey Model 840
56944
Zcopzqnp said
We’d like to invite you for an interview Pthc Ranchi
gtr
Yngrbiur said
I can’t stand football http://yqebecypac.de.tl little illegal cp My dick is bigger than any fag who commented on this pathetic video!!! i would have made her cum all over the place right before i creamed her pussy!
Gandalf said
Hello,
nice blog and great article!!!
Here I found something interesting by user ididdi:
http://www.mcseboard.de/topic/179103-outlook-automatisches-füllen-der-postfach-absenderadresse
unfortunately in german
Bye
Gandalf