我想向用户发送如下电子邮件:
这是验证码
用户名:xyz
代码:xyz
这是我关于电子邮件的所有代码:
StringBuilder emailMessage = new StringBuilder();
emailMessage.Append("Here is the Verification Code.");
emailMessage.Append(Environment.NewLine);
emailMessage.Append("UserName: " + UsernameTextBox.Text).AppendLine();
emailMessage.AppendLine();
emailMessage.Append("Code: " + newCode);
MailMessage email = new MailMessage();
email.To.Add(new MailAddress(emailAddress));
email.Subject = "Subject";
email.Body = emailMessage.ToString();
email.IsBodyHtml = true;
//Send Email;
SmtpClient client = new SmtpClient();
client.Send(email);
此代码使用单行发送邮件,即这里是验证码。用户名:xyz 代码:xyx
我尝试使用emailMessage.Append(Environment.NewLine);
我也尝试过"\n"
,\r\n
但没有任何效果。它有什么问题或我在哪里遗漏了什么?