.NETGURU
HTML Format Mails with embedded images
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-mail' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Jacob Kruger
-- Moved from [aspngfreeforall] to [ngfx-mail] by Tony Stark <Click here to reveal e-mail address> --

How do I add embedded images to an HTML format mail message?

Cheers

Jacob Kruger
Web Developer
Click here to reveal e-mail address

Reply to this message...
 
    
Dot Net Guru Serdar
be sure to use the full path such as

<img src="http://www.msn.com/images/myimage.gif";>

hth

matt

-----Original Message-----
From: Jacob Kruger [mailto:Click here to reveal e-mail address]
Sent: Monday, July 15, 2002 11:59 PM
To: ngfx-mail
Subject: [ngfx-mail] HTML Format Mails with embedded images

-- Moved from [aspngfreeforall] to [ngfx-mail] by Tony Stark
<Click here to reveal e-mail address> --

How do I add embedded images to an HTML format mail message?

Cheers

Jacob Kruger
Web Developer
Click here to reveal e-mail address

| [ngfx-mail] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-mail.asp = JOIN/QUIT

Reply to this message...
 
    
Jacob Kruger
The problem is I don't want to link to the image, I specifically want it
embedded in the mail message itsself so that, for example, someone with
no web access can view the complete message.

Cheers

Jacob Kruger
Web Developer
Click here to reveal e-mail address

[Original message clipped]

Reply to this message...
 
    
If you use CDOEX (CDO for Exchange 2000)/CDOSYS (CDO for Windows
2000/.NET) you can use the CreateHTMLBody method of the CDO.Message
object which will and the whole HTML page and automatically embed the
images.

<Cheers:Siegfried runat=3D"server" />

[Original message clipped]

Reply to this message...
 
    
dave wanta (VIP)
I don't believe there is an easy way to do this. The most reliable way to
do this is to use a 3rd party component.

The www.aspNetEmail.com component has the EmailMessage.EmbedImage() method
to do this for you.

--dave

----- Original Message -----
From: "Jacob Kruger" <Click here to reveal e-mail address>
To: "ngfx-mail" <Click here to reveal e-mail address>
Sent: Tuesday, July 16, 2002 9:53 AM
Subject: [ngfx-mail] RE: HTML Format Mails with embedded images

[Original message clipped]

Reply to this message...
 
    
dave wanta (VIP)
I'm assuming you have to Interop this?

Haven't seen it done before with .NET.

thanks,
dave
----- Original Message -----
From: <Click here to reveal e-mail address>
To: "ngfx-mail" <Click here to reveal e-mail address>
Sent: Tuesday, July 16, 2002 10:32 AM
Subject: [ngfx-mail] RE: HTML Format Mails with embedded images

If you use CDOEX (CDO for Exchange 2000)/CDOSYS (CDO for Windows
2000/.NET) you can use the CreateHTMLBody method of the CDO.Message
object which will and the whole HTML page and automatically embed the
images.

<Cheers:Siegfried runat="server" />

[Original message clipped]

| [ngfx-mail] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-mail.asp = JOIN/QUIT

Reply to this message...
 
    
Correct. Those are COM components which offer way more features than the
built-in System.Web.Mail. Sorry that I didn't mention that in my
previous post.

<Cheers:Siegfried runat=3D"server" />

[Original message clipped]

Reply to this message...
 
    
Jacob Kruger
Issue has been resolved.

As a matter of interest, using CDO, you get the same problem, but
aspNetEmail works beatifully.

Problem was specifically with web-based e-mail clients such as yahoo.
The messages were coming through without the embedded images. With CDO,
yahoo was stripping them out and displaying them as attachments, instead
of in-line where they belonged.

Cheers

Jacob Kruger
Web Developer
Click here to reveal e-mail address

[Original message clipped]

Reply to this message...
 
    
Armand Du Plessis
Just attach the images and in your code use <img> tag without full path.
works for me. here's some code.

cheers

armand
Click here to reveal e-mail address

using System;
using System.Web;

namespace embeddedemailtest
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            System.Web.Mail.MailMessage msg = new
System.Web.Mail.MailMessage();
            System.Web.Mail.MailAttachment mAttach = new
System.Web.Mail.MailAttachment(@"e:\embeddedimage.gif");
            
            msg.Attachments.Add(mAttach);

            msg.BodyFormat = System.Web.Mail.MailFormat.Html;
            
            string bodyHTML = "<html><head></head><body>" +
                "<font face=\"3\" color=\"red\">" +
                "Hello, I'm a message with an embedded image
sort of</font><br><br>" +
                "<img src=\"embeddedimage.gif\">" +
                "</body></html>";

            
            

            msg.Body = bodyHTML;
            
            msg.To = "Recipient <Click here to reveal e-mail address>";
            msg.From = "Sender <Click here to reveal e-mail address>";

            System.Web.Mail.SmtpMail.SmtpServer = "x.x.x.x";
            System.Web.Mail.SmtpMail.Send(msg);
            Console.WriteLine("Sent");
            Console.ReadLine();

        }
    }
}

-----Original Message-----
From: dave wanta [mailto:Click here to reveal e-mail address]
Sent: 16 July 2002 05:39
To: ngfx-mail
Subject: [ngfx-mail] RE: HTML Format Mails with embedded images

I don't believe there is an easy way to do this. The most reliable way to
do this is to use a 3rd party component.

The www.aspNetEmail.com component has the EmailMessage.EmbedImage() method
to do this for you.

--dave

----- Original Message -----
From: "Jacob Kruger" <Click here to reveal e-mail address>
To: "ngfx-mail" <Click here to reveal e-mail address>
Sent: Tuesday, July 16, 2002 9:53 AM
Subject: [ngfx-mail] RE: HTML Format Mails with embedded images

[Original message clipped]

| [ngfx-mail] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-mail.asp = JOIN/QUIT

Reply to this message...
 
    
Jacob Kruger
Tested it an it still doesn't display the images in-line when you send
the message to a web-based account like yahoo, or, locally, webmail.

Only thing that seems to work consistently is aspnetmail.

Cheers

Jacob Kruger
Web Developer
Click here to reveal e-mail address

[Original message clipped]

Reply to this message...
 
 
System.Console
System.Web.Mail.MailAttachment
System.Web.Mail.MailFormat
System.Web.Mail.MailMessage
System.Web.Mail.SmtpMail




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification