1

In VB.Net (Or C#) when I create the code to send out an email, I always set the "sender" to an email on my server instead of the email of the person who's filling the form.

Little example:

System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()

mailMessage.From = New System.Net.Mail.MailAddress("[email protected]")

mailMessage.To.Add(New System.Net.Mail.MailAddress("[email protected]"))

This is important because most hosting providers restrict using an email which relies outside of your hosting environment to send out an email (security purposes which I totally understand).

The above works really well, but the problem is when someone wants to reply to the email, they are actually going to be replying to their own email address, unless they manually copy the email of the person from the content of the message and put it in the "To" field while replying.

I would like to know what are the best practices today in order to deal sending emails.

I see some emails I get with "On Behalf Of" and others with "Reply To".

Is there anything else I am missing here? Please advice.

1 Answer 1

1

Working with SMTP MailMessage, i always use ReplyTo and it works:

rawMessage.ReplyTo = New MailAddress("[email protected]");

But for outlook Interop, it's the OnBehalfOf...

EDIT:

As you are using vs2010, ReplyTo is obsolete, ReplyToList may be used:

rawMessage.ReplyToList.Add("[email protected]");

EDIT:

Sorry I misunderstood the original question - actually it's looking for the difference between the two: OnBehalfOf and ReplyTo,

as far as I know, at the MailMessage object, if you set Sender with a different email address other than the From address, the client (outlook for instance) will show "On Behalf Of".

but if you set the ReplyTo, the client would not show that, instead, it populates the To field automatically if user clicks Reply/ReplyAll

it really depends on your needs to decide which one to use.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. I know about ReplyTo and I use it sometimes. I am just making sure those are best practices nowadays. Just to keep myself up to date. Any ideas about "On Behalf Of"? Is it something we should use?
I used OnBehalfOf only with MailItem (outlook interop or redemption). -- sorry I misunderstood your question. i will update my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.