Hi,
I have a business application but I want the email address [email protected] 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 [email protected] to [email protected]
I thought the code below would work but it still arrives as the Gmail address.
C#
MailMessage onboarding = new MailMessage();
onboarding.From = new MailAddress("[email protected]");
onboarding.To.Add(new MailAddress("[email protected]"));
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("smtp.gmail.com", 587);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("[email protected]", "Password");
try
{
client.Send(onboarding);
lblError.ForeColor = System.Drawing.Color.Blue;
lblError.Text = "Onboarding request successful";
}
catch
{
lblError.Text = "Mail failed to send";
}
Sachin SinghRank #66 · 26.2K reputationPosted Jul 7, 2021, 6:36 AM EDT
Chris Johnson47 reputationPosted Jul 7, 2021, 6:42 AM EDT
Hi Sachin,
so onboarding.From = new MailAddress("[email protected]"); will never work?
Sachin SinghRank #66 · 26.2K reputationPosted Jul 7, 2021, 7:07 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Jul 8, 2021, 2:11 AM EDT
wahab ahmed99 reputationPosted Jan 19, 2022, 2:31 AM EST
Shweta LodhaRank #31 · 39.8K reputationPosted Jan 20, 2022, 9:05 PM EST