C#mail未在我的电子邮件中显示链接
我正在尝试在我的aspx页面中发送带有不可分发链接的电子邮件。但当我检查我的电子邮件id时,它只显示文本。没有联系。这是我生成电子邮件的代码C#mail未在我的电子邮件中显示链接,c#,asp.net,email,smtp,C#,Asp.net,Email,Smtp,我正在尝试在我的aspx页面中发送带有不可分发链接的电子邮件。但当我检查我的电子邮件id时,它只显示文本。没有联系。这是我生成电子邮件的代码 string bodyContent = CKEditor1.Text; string userLink = "http://www.abc.in/Message.aspx?action=rmsb&oldsubuser="; string footerL
string bodyContent = CKEditor1.Text;
string userLink = "http://www.abc.in/Message.aspx?action=rmsb&oldsubuser=";
string footerLink = "</br></br></br>You are receiving this mail because you have subscribed to our newsletter. If you do not wish to receive the mail, Click <a href='" + userLink + "" + ids[i].ToString() + "'>Here</a>";
bodyContent = bodyContent + footerLink;
EmailSend newsletter = new EmailSend();
newsletter.NewsLetterSend(ids[i].ToString(), bodyContent.Replace("'", "''"), txtSubject.Text.Replace("'", "''"));
//EmailSend.SendMailMessage("faredpt@gmail.com", ids[i].ToString(), "", "", txtSubject.Text, bodyContent);
bodyContent = bodyContent.Replace(footerLink, " ");
现在此代码已成功发送电子邮件,但无法在我的电子邮件中添加链接。它显示简单的文本
请告诉我为什么会发生这种情况你能试着用
替换
吗?可能是因为无效的br
标记,您的电子邮件被视为无效的HTML,链接被破坏。您正在用两个引号替换href
中的引号
无效语句:bodyContent.Replace(“”,“”)
这将使您的HTML无效。bodyContent.Replace(“”,“”)
为什么会发生这种情况?
public void NewsLetterSend(string getemailAdd, string msgBody, string subject)
{
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("admin@abc.in", "admin@abc.in");
mail.To.Add(getemailAdd.Trim());
//set the content
mail.Subject = subject;
mail.IsBodyHtml = true;
mail.Body = msgBody;
mail.Priority = MailPriority.High;
//set the smtp settings
SmtpClient smtp = new SmtpClient("abc.in");
smtp.EnableSsl = false;
smtp.Credentials = new System.Net.NetworkCredential("admin@abc.in", "i@abc!23#");
//smtp.Port = 3535;
smtp.Port = 25;
//send email
smtp.Send(mail);
return;
}