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.
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";
}
Shweta LodhaPosted Jan 21, 2022, 2:05 AM
wahab ahmedPosted Jan 19, 2022, 7:31 AM
Nitin SontakkePosted Jul 8, 2021, 6:11 AM
Sachin SinghPosted Jul 7, 2021, 11:07 AM
Chris JohnsonPosted Jul 7, 2021, 10:42 AM
Hi Sachin,
so onboarding.From = new MailAddress("[email protected]"); will never work?
Sachin SinghPosted Jul 7, 2021, 10:36 AM