通过asp.net mvc发送电子邮件时未创建链接

时间:2018-01-08 06:08:24

标签: c# asp.net-mvc

您好我在电子邮件中发送下载手册链接,但我只收到文本而不是邮件中的链接

下面的

是我发送邮件的代码

        StringBuilder sb = new StringBuilder();
        sb.Append("<html><body><a href='"+Server.MapPath("~/Documents/Brochure.pdf") +"'>Download Brochure </a>");
        sb.Append("<br></body></html>");


        string messageBody = sb.ToString();
        string AdminEmail = ConfigurationManager.AppSettings["AdminEmailForEmail"];
        string AdminPassword = ConfigurationManager.AppSettings["AdminPasswordForPassword"];
        string Reciepient = Email;
        string subject = "Brochure Download";

        string FromMail = "info@testmail.in";
        string emailTo = Reciepient;
        MailMessage mail = new MailMessage();
        SmtpClient SmtpServer = new SmtpClient("testmail.in");
        mail.From = new MailAddress(FromMail);
        mail.To.Add(emailTo);
        mail.Subject = subject;
        mail.IsBodyHtml = true;
        mail.Body = messageBody;
        SmtpServer.Port = 25;
        SmtpServer.Credentials = new System.Net.NetworkCredential(AdminEmail, AdminPassword);
        SmtpServer.EnableSsl = false;
        try
        {
            SmtpServer.Send(mail);
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }

0 个答案:

没有答案