Define a constant string for MailBody
public static string MailBody = "Dear [CandidateName], this is automail we will get back to you soon. Regards ABC"
Make a method to replace the candiate name in mail body
public string FormatMailBody(string candidateName)
{
return this.MailBody.Replace("[CandidateName]",candidateName);
}
call this method in a string to get the customized mail body and send that string in mail.
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = FormatMailBody(candidateName);
SmtpClient client = new SmtpClient(server);
client.UseDefaultCredentials = true;
try {
client.Send(message);
}
catch (Exception) {
}