I saw some examples here, but I'm actually doing the same thing, however, it does not fully work. So, this is my question:
I have the code in my controller to generate URL:
string link = @Url.Action("Index", "Details", new System.Web.Routing.RouteValueDictionary(new { id = newId }), "http", Request.Url.Host);
var strUrl = "<a href='"
+ @Url.Action("Index", "Details", new System.Web.Routing.RouteValueDictionary(new { id = Id }), "http", Request.Url.Host)
+ "'>Click here</a>";
Then I send an email:
var response = EmailHelper.SendApproveTicketEmail(myModel.Id, strUrl);
This is my Send Email code:
public static SaveResult SendEmail(int ID, string Url)
{
var email = new Email
{
Recipients = Configuration.EmailTo,
Body = Configuration.EmailBody + ID.ToString() + "." + System.Environment.NewLine + "Click the following link to open the details page:" + ticketUrl,
Sender = Configuration.EmailFrom,
Subject = Configuration.EmailSubject,
Cc = Configuration.EmailCC
};
return FormatResult(_client.SendEmail(Configuration.ApplicationName, 0, email));
}
The following email is received:
The following item needs to be approved:0011 Click the following link to open the item details page:<a href='http://localhost:51335/Details/Index/001'>Go to your item</a>
The URL is built successfully, however, it is not clickable.
What am I missing?
ticketUrl? Are you sending email from a Razor file???MailMessage.IsBodyHtmlis settrue