Monday 15 June 2015

c# - Set "From" address when using System.Net.Mail.MailMessage? -


I'm trying to send a password reset email, but I have trouble finding out how to specify the sender's address Getting Started

What I'm trying to do here:

  MailMessage Mail = New MailMessage (); Mail.From.Address = "support@mycompany.com"; Mail.To.Add (email); Mail.Subject = "Forgot Password"; Mail.Body = "& lt; a href = \" "+ url +" \ "& gt; Click here to reset your password. & Lt; / a & gt;"; SmtpClient smtp = new SmtpClient (); Smtp.SendAsync (mail, blank);   

I'm sure this is possible, so how can I do it in ASP.NET?

It is revealed that I was moving forward by myself.

Set the Allow Mail.formed editor to address , but type MailAddress is required.

Here's the solution:

  MailMessage Mail = New MailMessage (); similarity. From = new mail address ("support@mycompany.com"); Mail.To.Add (email); Mail.Subject = "Forgot Password"; Mail.Body = "& lt; a href = \" "+ url +" \ "& gt; Click here to reset your password. & Lt; / a & gt;"; SmtpClient smtp = new SmtpClient (); Smtp.SendAsync (mail, blank);    

No comments:

Post a Comment