Chris Johnson

Chris Johnson

  • 2.1k
  • 37
  • 2.4k

Is it possible to change the FROM email address in c#?

Jul 7 2021 10:14 AM


I have a business application but I want the email address to give a more meaningful from address.
As you can see below I am using gmail but I wish to use our official url as the email address. I could and will of course use our official ORMS server but this is just a system I wish to demonstrate. 

So to

I thought the code below would work but it still arrives as the Gmail address.

MailMessage onboarding = new MailMessage();
onboarding.From = new MailAddress("");
onboarding.To.Add(new MailAddress(""));
onboarding.Subject = "You have an Onboarding request";
onboarding.Body = "You have a new onboarding request from " + " " + Requestor.Text + " for " + Name.Text + ". " + "\r\n";
onboarding.IsBodyHtml = true;
SmtpClient client = new SmtpClient("", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("", "Password");
    lblError.ForeColor = System.Drawing.Color.Blue;
    lblError.Text = "Onboarding request successful";

    lblError.Text = "Mail failed to send";


Answers (6)