Reputation: 1479
So im implementing a mailservice in our webapp that users can utilize to send out emails to persons on a certain list. Now i need to know how to best use the System.Net.Mail object to send mail on the users behalf. Ive been trying this now for a while without the right results.
I would like the mail to read "our system on behalf of user 1" and the reply to adress should be the adress that user1 has in our system so that when the contacted person wants to reply to the mail he should get user1:s address, not ours. How can I do this?
Which fields do I need to declare and how? This is how i have it set up right now, but a reply to these settings sends a mail back to [email protected]
from = '[email protected]'
replyTo = '[email protected]'
to = '[email protected]'
sender = '[email protected]'
cc = ''
Upvotes: 4
Views: 5857
Reputation: 1479
This was caused by a programming error on the receiving end. The correct solution is to set the from and replyto as above. That will get the correct behaviour.
Upvotes: 0
Reputation: 1328
ReplyTo is obsolete
. You should use ReplyToList
Example:
MailAddress mailFrom = new MailAddress("[email protected]");
MailAddress mailTo = new MailAddress("[email protected]");
MailAddress mailReplyTo = new MailAddress("[email protected]");
MailMessage message = new MailMessage();
message.From = mailFrom;
message.To.Add(mailTo); //here you could add multiple recepients
message.ReplyToList.Add(mailReplyTo); //here you could add multiple replyTo adresses
Upvotes: 2