string UserName = SessionManager.Instance.FIRSTNAME.ToString() + " " + SessionManager.Instance.LASTNAME.ToString();
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(SmtpClient);
string palinBody = "Your mail server don't support html content.";
AlternateView plainView = AlternateView.CreateAlternateViewFromString(palinBody, null, "text/plain");
mail.From = new MailAddress(MailFrom);
mail.To.Add(MailTo);
mail.CC.Add(MailCC);
mail.Subject = "Update on Your PI Submission";// mailsubject;
mail.IsBodyHtml = true;
string MailBodies = @"
Dear {UserName},
We would like to inform you that the PI point you raised, [PI Title], has now been closed. Thank you for helping us enhance our processes.
Best regards,
Sanjeet Rawat
Safety Head
Jaimin ShethiyaPosted May 13, 2024, 12:03 PM
Hello Sandeep,
Try the below code.
Thanks
Rajeesh MenothPosted May 13, 2024, 10:59 AM
Hi,
You can try out my inline email sending article in C# corner.
https://www.c-sharpcorner.com/UploadFile/2a6dc5/send-email-to-multiple-email-addresses-with-inline-image-usi/
Sandeep KumarPosted May 13, 2024, 10:34 AM
not working
Jayraj ChhayaPosted May 13, 2024, 10:20 AM
To insert the
UserNamevariable into the email body, you can use string interpolation or concatenation within theMailBodiesstring.By using string interpolation (
$"{UserName}") or concatenation ("Dear " + UserName + ","), you can dynamically insert theUserNamevariable into the email body before sending the email.