小弟在做一个邮件客户端程序,想实现直接发送网页的功能(比如说发送www.google.cn,别人收到邮件后直接显示google首页)。但是遇到一个小问题,正如标题所说,用www.google.cn作例子,收到邮件后却无法显示google的logo,请问这是怎么回事?我试过发送www.mydrivers.com和www.sina.com,大部分图片都是可以显示的啊。下面是我的代码(都是网上抄的,唉):
using System;
using System.Net;
using System.IO;
using System.Net.Mail;
using System.Net.Mime;
using System.Threading;
using System.ComponentModel;
using System.Text;
public static string ScreenScrapeHtml(string url)
        {
            WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
            StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream(),Encoding.GetEncoding("GB2312")  );
            string result = sr.ReadToEnd();
            sr.Close();
            return result;
        }
        public static void EmailWebPage()
        {
            string FromMail = "[email protected]";//发件人
            string Title = "mailnow测试邮件"; //邮件主题
            string ShowName = "paladintsy";//显示名字
            string MailUserName = "tangsiyanking";
            string MailPassword = "xxxxxx";//密码,我就不给了
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.From = new MailAddress(FromMail, ShowName, System.Text.Encoding.UTF8);
            msg.Subject = Title;//邮件标题 
            msg.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码 
            msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
            msg.Priority = MailPriority.Normal;//邮件优先级 
            //screen scrape the html
            string html = ScreenScrapeHtml("http://www.google.cn/");
            msg.IsBodyHtml = true;
            msg.Body = html;
            msg.To.Add("[email protected]");
            //send the message
            SmtpClient sender = new SmtpClient();
            sender.Host = "smtp.sina.com";
            sender.Credentials = new System.Net.NetworkCredential(MailUserName, MailPassword);
            sender.Port =25; // Gmail 使用 465 和 587 端口 ,其他邮箱是25端口
            sender.EnableSsl = false; // 如果使用GMail,则需要设置为true ,否则是false
            sender.Send(msg);
        }

解决方案 »

  1.   

    回1楼,Windows Live Mail发送的www.google.cn是可以显示的。有没有什么办法解决这个问题?
      

  2.   

    回3楼,确实完全不懂html。我以前就没有接触过这些东西。没办法,大学呆得太堕落了啦。
    你就说出来嘛,不懂的部分我可以慢慢去看,我现在最富余的就是时间啦
      

  3.   

    因为Google用的相对地址... 
    你需要把图片copy下来存为附件, 修改HTML中的图片地址.
      

  4.   

    图片看不到,最直接的反射动作是看图片的属性解决你的办法是替换图片的src属性,使用绝对地址