473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Images in HTML

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
Nov 15 '05 #1
9 1509
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="te**@test.net";
SmtpMail.SmtpServer="localhost";
mail.From="te**@test.net";
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....
T.Michelle wrote:
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

Nov 15 '05 #2
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

"Ruprict" <ru*****@bellsouth.net> wrote in message
news:Hl*******************@bignews1.bellsouth.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="te**@test.net";
SmtpMail.SmtpServer="localhost";
mail.From="te**@test.net";
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....
T.Michelle wrote:
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

Nov 15 '05 #3
"Jerry III" <je******@hotmail.com> wrote in news:eXr1fP44DHA.2576
@TK2MSFTNGP11.phx.gbl:
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.
> I searched over the net ... and got to know that I have to use PAID third >
> party tools. I can not believe this.
Third party, but not paid. :)
> coz in my 9 yrs experience I have never come across a situation where I
> could not achieve something with Microsoft.


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

Nov 15 '05 #4
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?

Jerry III wrote:
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

"Ruprict" <ru*****@bellsouth.net> wrote in message
news:Hl*******************@bignews1.bellsouth.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="te**@test.net";
SmtpMail.SmtpServer="localhost";
mail.From="te**@test.net";
mail.Attachments.Add(new MailAttachment("c:\\temp\\progressbar.gif"));
mail.BodyFormat=System.Web.Mail.MailFormat.Htm l;
mail.Body="<html><body>test<img src='progressbar.gif'/></body></html>";
SmtpMail.Send(mail);
Hope this helps....
T.Michelle wrote:

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


Nov 15 '05 #5
Ruprict <ru*****@bellsouth.net> wrote in
news:kL*******************@bignews6.bellsouth.net:
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

Nov 15 '05 #6
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.

Chad Z. Hower aka Kudzu wrote:
Ruprict <ru*****@bellsouth.net> wrote in
news:kL*******************@bignews6.bellsouth.net:
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

Nov 15 '05 #7
Ruprict <ru*****@bellsouth.net> wrote in
news:R3******************@bignews6.bellsouth.net:
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

Nov 15 '05 #8
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)

--
Regards,
HD
Once a Geek.... Always a Geek
"Chad Z. Hower aka Kudzu" <cp**@hower.org> wrote in message
news:Xn*****************@127.0.0.1...
Ruprict <ru*****@bellsouth.net> wrote in
news:R3******************@bignews6.bellsouth.net:
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

Nov 15 '05 #9
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in news:OWi
$W***********@TK2MSFTNGP12.phx.gbl:
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

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave | last post by:
Hi, I have an app that uses rollover images, but the images are still pulled from the web server during a mouseover instead of being pulled from memory. The code is as follows: the...
3
by: Tim T | last post by:
Hi, I hope there is someone reading this that has the answer, Please Help! I have the need to send a html email via asp.net. its easy enough to send an html email and add attachments. My...
9
by: Jeff | last post by:
I get the following error when I try to rollover my button: document.images has no properties Line: 22 Am I doing this correctly? Suggestions? This is using Netscape 7.2 on Fedora core 4. ...
10
by: Neo Geshel | last post by:
I am seeking to hand-roll my own blog in ASP.NET 2.0 and SQLExpress 2005. Why? Because I can. Because I will gain experience. The one thing that has me stumped at square one is inline images....
61
by: phil-news-nospam | last post by:
Why does SVG need a different tag than other images? IMHO, SVG should be implemented as an image type just like any other image type, allowing it to work with <img> tags, and ... here is the...
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores” project...
7
by: Leoa | last post by:
Hi All, I'm having a hard time figuring out the DOM syntax to get one frame that has thumnails of images to display at full size in another frame (onmouseover). I looked at a couple...
2
by: wstsoi | last post by:
hi I have to read images from spreadsheet, is it possible to do with php?
2
by: FairyLucy | last post by:
Hello web experts, a question form a lonely beginner in HTML and CSS crying out for help!!, I am trying to stack 5 images of the same dimensions next to each other horizontally as the top bar of...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.