Images in HTML

  • Thread starter Thread starter T.Michelle
  • Start date Start date
T

T.Michelle

We have few Mail templates (.html) which we

use to send mails.

We want to have some Logo in that ie ... when I send the mail to user the

image should go as in-line embedded

image in mail. I am not able to get this. I tried with

Message.Attachments.add ... but its sending the image

as an attachment. Please note I do not want to give any website URL to those

images coz we would be sending mails

to some users who do not have Internet Access. They should be able to see

the Images Offline.

I searched over the net ... and got to know that I have to use PAID third

party tools. I can not believe this.

coz in my 9 yrs experience I have never come across a situation where I

could not achieve something with Microsoft.

Do I have to use Cid (ContentId) ? If YES .. kindly let me know how do I

generate this Cid ?

Kindly let me know how to send HTML mails with in-line embedded images using

C# and ASP.Net
 
Hi,

This should just be a matter of setting your src attributes to the image
name and attaching each image to the mail.

This works for me:

// Put user code to initialize the page here\
MailMessage mail = new MailMessage();
mail.To="(e-mail address removed)";
SmtpMail.SmtpServer="localhost";
mail.From="(e-mail address removed)";
mail.Attachments.Add(new MailAttachment("c:\\temp\\progressbar.gif"));
mail.BodyFormat=System.Web.Mail.MailFormat.Html;
mail.Body="<html><body>test<img src='progressbar.gif'/></body></html>";
SmtpMail.Send(mail);


Hope this helps....
 
No it won't help, to do that you have to send the e-mail as MIME formatted,
mutlipart/related content type. MailMessage doesn't support this, you need
to write your own class (or find one) that does.

Jerry
 
Jerry III said:
No it won't help, to do that you have to send the e-mail as MIME
mutlipart/related content type. MailMessage doesn't support this, you
to write your own class (or find one) that does.

http://www.indyproject.org/indy.html

Fully supports MIME and more in messages. Its absolutely free too. :)

If you need help with writing sample code for Indy, you can ask here or in
the Indy newsgroups.

Third party, but not paid. :)

Im not sure what you've been doing, but its a daily experience for me. :)


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
But I did it and it WORKED. Image was inline just as I specified. I
even tried various HTML tags on the page to move the image around (put
it in a <ul> for example) and it worked. In T. Michelle's case, he
would probably have to build the template in code, but it should still
work out of the box.

Excuse my ignorance, but I am just wondering what I am missing if my
images are showing up inline....

Did you try the code below? Does it matter that I am running IIS?
 
Ruprict said:
But I did it and it WORKED. Image was inline just as I specified. I
even tried various HTML tags on the page to move the image around (put
it in a <ul> for example) and it worked. In T. Michelle's case, he
would probably have to build the template in code, but it should still
work out of the box.

What mail client did you use to look at it with? On quick glance its not a
compliant message, and you are just lucky that the client you used is fixing
it up. You will very likely have less success if at all with most clients.
Does it matter that I am running IIS?

No. Mail servers generally do not modify mail.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
I was using Outlook for initial tests, but I just tried it with
Thunderbird and no dice....


So, the problem seems to be mail clients, not the MailMessage object
itself....yes? Or maybe a combo of both?

Thanks for the knowledge, btw.
 
Ruprict said:
So, the problem seems to be mail clients, not the MailMessage object

NOOO!!! I knew you were using Outlook. Outlook like IE fixed up all kinds of
poorly and non standard type HTML.

Which is good - EXCEPT that people use Outlook and IE to "verify" and then
assume they have good HTML (or mail messages). They then later find out
Netscape or something doesnt like it and blame it, when really its their
code. Netscape and others follow the standards much closer to the letter and
dont try to do fix ups.

You can probably do it with MailMessage, but its going to be a nightmare
managing all the headers and trying to get the mime markers exactly right.

Indy does all of this for you and is free - Unless you are opposed to using
something that is free, has over a million deployments, is well supported,
and works.....

http://www.indyproject.org/indy.html


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
Well not necessarily correct. In my experience netscape doesnt follow most
standards to full extent.
Atleast ie is forgiving with things. NS just comes out as a necessary evil
(considering it still has a 5% market)
 
Hermit Dave said:
Well not necessarily correct. In my experience netscape doesnt follow most
standards to full extent.

NS4 is old. The newer NS is quite strict about standards.
Atleast ie is forgiving with things. NS just comes out as a necessary evil
(considering it still has a 5% market)

Its not only NS. Most other mailers follow the standards pretty strict.
Outlook and IE are the ones that "fix up" things, and this causes the
problems I mentioned because people use them as verification.

If you write badly formed code, dont blame the non MS tools when they dont
interpret it correctly. Its like asking Uncle Bubba to help you with you
spelling test and then getting mad at your teacher for correcting you.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com
 
Back
Top