Sendgrid-能够将明文与html超链接连接起来

时间:2017-04-14 11:54:41

标签: c# sendgrid

我正在使用sendgrid发送电子邮件但是当我尝试连接明文和html超链接时,它似乎构造正确但在电子邮件中我得到了html标签。

我的代码:

                string myHtml = string.Format(@"<a href='{0}'>here</a>", activationLink);
                string message = string.Format("Dear {0} {1}\n", FirstName, LastName) + "to verify your email address click ";
                SendMail(Email, subject, message, myHtml);      

以下是我的sendmail方法:

    public bool SendMail(string To, string Subject, string Message, string htmlContent)
    {
        try
        {
            var client = new SendGridClient(ConfigurationManager.AppSettings["Key"].ToString());
            EmailAddress from = new EmailAddress(ConfigurationManager.AppSettings["From"].ToString());
            var subject = Subject;
            EmailAddress to = new EmailAddress(To);
            string content = Message;
            //var htmlContent = "<strong>Hello, Email!</strong>";
            var msg = MailHelper.CreateSingleEmail(from, to, subject, content, htmlContent);
            var response = client.SendEmailAsync(msg);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }

这是我在电子邮件中收到的内容:

    here(Clickable)

我希望在邮件中出现的内容是:

    Dear User to verify your email address click here (Clickable)

任何人都可以帮助我。

0 个答案:

没有答案