Sandeep Kumar

Sandeep Kumar

  • 1.1k
  • 683
  • 60.6k

how to insert UserName variable in Body while mailing

May 13 2024 9:58 AM

  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 = @"<html>

                      <body>
                      <p>Dear {UserName},</p>
                      <p>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.</p>
                      <p>Best regards,<br>Sanjeet Rawat</br> <br>Safety Head</br></p>

                      </body>

                      </html>


Answers (4)