日期:2014-05-20  浏览次数:20951 次

如何在邮件中附加链接
private   string   HttpContent(string   URL)
{
    WebRequest   objRequest=System.Net.HttpWebRequest.Create(URL);
      StreamReader   sr=new   StreamReader(objRequest.GetResponse().GetResponseStream(),System.Text.Encoding.Default);
    string   result=sr.ReadToEnd();
    sr.Close();
    return   result;
}

private   void   Button1_Click(object   sender,   System.EventArgs   e)
{
string   URL= "http://www.haokan123.com ";
MailMessage   MailObj=new   MailMessage();
MailObj.From=from.Text.Trim();
MailObj.To=to.Text.Trim();
MailObj.Subject=subject.Text.Trim();
MailObj.Body=content.Text.Trim()+HttpContent(URL);
MailObj.BodyFormat=MailFormat.Html;
MailObj.BodyEncoding=System.Text.Encoding.GetEncoding( "gb2312 ");
string   filename=this.file.PostedFile.FileName.ToString();
MailObj.Attachments.Add(new   MailAttachment(filename));//添加附件
MailObj.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ",   "1 ");
MailObj.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername ",   "username ");
MailObj.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ",   "userpwd ");
SmtpMail.SmtpServer   =   "smtp.163.com ";
SmtpMail.Send(MailObj);
Response.Write( "success ");
}

参考网上的代码.想实现邮件正文中可以有超链接,可是这样做不能达到效果.我该如何修改.请路过的赐教


------解决方案--------------------
有时候自己多测试一下就会解决的