我正在使用 razorengine 发送电子邮件。senden不是问题,只是内容在内容中只显示为/da/Property/Property/Mail/TellAFriendTextMail。
private void SendTellAFriendMail(NotificationTellAFriend mailData)
{
string textmail = this.GetMailAsText(mailData);
string htmlmail = this.GetMailAsHTML(mailData);
MailAddress from = new MailAddress("robot@mail.com", mailData.SenderName);
MailAddress to = new MailAddress(mailData.receiverMail, mailData.SenderName);
using (AlternateView htmlview = this.CreateView(htmlmail, "text/html"))
using (AlternateView textview = this.CreateView(textmail, "text/plain"))
using (MailMessage email = new MailMessage(from, to))
{
email.Subject = string.Format(CultureInfo.InvariantCulture, Resources.Resources._MailSubject, mailData.SenderName);
email.AlternateViews.Add(textview);
email.AlternateViews.Add(htmlview);
email.ReplyToList.Add(new MailAddress(mailData.receiverMail, mailData.SenderName));
using (SmtpClient client = new SmtpClient())
{
client.Send(email);
}
}
}
private string GetMailAsHTML(NotificationTellAFriend mailData)
{
return Razor.Parse(Url.Action("/Property/Mail/TellAFriendTextMail"), mailData);
}