开发者

Email send via SmtpClient does not display images

The following code produces an email which the image is visible via webmail clients such as gmail but is not visible via thunderbird or outlook clients. A broken link is visible in these clients and for some reason it does not prompt me to load images. When the same email is forwarded from another client it does prompt me to load the images and everything behaves as expected.

 class Program 
{
    static void开发者_如何转开发 Main(string[] args)
    {
        var mesg = new MailMessage("destination@somewhere.com","from@somewhere.com");
        mesg.Body = "<img src='http://localhost/images/bangs.JPG' />";
        mesg.Subject = "Image Spike Test";
        mesg.IsBodyHtml = true;
        var client = new SmtpClient("localhost");
        client.Send(mesg);

    }
}

Here is the email source that is produced by this code.

MIME-Version: 1.0
From: destination@somewhere.com
To: from@somewhere.come
Date: 9 Jul 2011 09:25:08 -0500
Subject: Image Spike Test
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

<img src=3D'http://localhost/images/bangs.JPG' />


Well, if you send a mail like that, your email reader will have to go to register.cwh.com to ask for the image. That would tell register.cwh.com when, and from where, the email was being read. Outlook and other email clients protect your privacy and do not retrieve the image. I'm somewhat suprised that GMail does load them.

A proper fix is to send the image as an attachment. Outlook will display images from attachments.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜