Archived Forum Post

Index of archived forum posts

Question:

Send Email to Show Sent on Behalf of Somebody

Nov 30 '15 at 10:23

I’m trying to get the email to show sent on the behalf of X, but it’s not working. I’ve added the following below. Using VB.net, and what am I missing?

email.ReplyTo = String.Format("{0} <{1}>", personsname, owneremail.Trim)

email.Sender = String.Format("{0} <{1}>", personsname, owneremail.Trim)


Answer

The email.ReplyTo property is simply going to set the Reply-To header. By default it is empty and no Reply-To header exists. (Receipients would normally reply to the From email address.)

The email.Sender property is a bit confusing, and should probably be deprecated and eventually removed. What it does is set's the CKX-Bounce-Address header field. Any header field beginning with "CKX-" is automatically removed from the email when SendEmail is called. The purpose of CKX-Bounce-Address is to use it as the "reverse path" for sent email. This is the argument to the "MAIL FROM" command in the SMTP protocol exchange. (It is NOT the "From" email header.)

See http://www.cknotes.com/smtp-protocol-in-a-nutshell/ Also see a sample SMTP session: http://www.hobgoblinconsulting.com/hints/smtp.html

I don't know what email header fields would correspond to "on behalf of", but I Googled the word "behalf" in combination with other pertinent terms and found this: https://tools.ietf.org/html/rfc4021

See sections "2.1.15. Header Field: Resent-From" and so-on. Any header field can be added to an email via the email.AddHeaderField method..


Answer

When there is both a "From:" and "Sender:" in the email header. Outlook will present in the From: {sender} on behalf of {from}

This behavior can be created and seen in Outlook 2010.

The Gmail web and Android interface do not show this "on behalf", nor does it show the "sender" information (without looking at all the headers).

This might be a Microsoft only implementation.

You're "Sender" option doesn't set the "Sender" header?


Answer

Thanks Tracy! I know it's confusing about the "Sender" property, but it can't be changed without breaking backward compatibility. (Perhaps in a major new version w/ explicit notes on backward compatibility issues..)

To set the "Sender" header, one would call email.AddHeaderField("Sender","...")