I’m using razorengine to send emails. The senden is not the problem, but the content is only displayed as /da/Property/Property/Mail/TellAFriendTextMail in the content.
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);
}
The first argument of the
Razor.Parsemethod is not an url but the actual Razor contents that you want to be parsed. So: