Emailing HTML and attachments

S

Steven Nagy

Hi,

I am sending an email in my .NET2.0 web app using:
System.Net.Mail.Attachment
System.Net.Mail.MailMessage

I can successfully send an HTML email with a background image, however
that image shows up as an attachment in the target email box.

If its possible, I would like to send HTML formatted emails where the
images don't all appear as attachments. I am guessing its something to
do with the way I am attaching my files; currently i only create a new
instance of the Attachment class, and add it to my MailMessage. Nothing
else.

Any hints?

Steve
 
F

Frans Bouma [C# MVP]

Steven said:
Hi,

I am sending an email in my .NET2.0 web app using:
System.Net.Mail.Attachment
System.Net.Mail.MailMessage

I can successfully send an HTML email with a background image, however
that image shows up as an attachment in the target email box.

If its possible, I would like to send HTML formatted emails where the
images don't all appear as attachments. I am guessing its something to
do with the way I am attaching my files; currently i only create a new
instance of the Attachment class, and add it to my MailMessage.
Nothing else.

html emails with graphics are send using mime-types, but it's
cumbersome. The main thing is that an image in a HTML email IS an
attachment, the emailreader simply sees it as part of the email, that
is.. it depends on the settings of the emailreader. So if I were you,
I'd store the images on a server somewhere and use <img
src="yourserver\image.jpg"> tags in the email instead.

FB

--
 
H

Hans Kesting

Steven said:
html emails with graphics are send using mime-types, but it's
cumbersome. The main thing is that an image in a HTML email IS an
attachment, the emailreader simply sees it as part of the email, that
is.. it depends on the settings of the emailreader. So if I were you,
I'd store the images on a server somewhere and use <img
src="yourserver\image.jpg"> tags in the email instead.

FB

BUT this will lead to warnings like "to protect your privacy, you will
have to do extra actions to show the images".

It should be possible using the "LinkedResource" class (System.Net.Mail
namespace) to refer directly to an attached image.
Sorry, I don't have experience with this (yet), so I can't help you
further.

Hans Kesting
 
S

Steven Nagy

We don't want the chances of an email rendering based on whether or not
they can see the server or not. This is email that goes to general
public and the server may not be accessible to them as such.

I know it can be done, because whenever I get spam about buying viagra,
the images aren't appearing in the attachment list with the email, even
though they must be attachments. So there must be a flag somewhere to
set.

Also as Hans says, you don't want them getting prompts as well.

Thanks Hans and Frans!
 
T

tdavisjr

You will always run into this issue when sending HTML formatted with
images. The only way I know around it is if you use the absolute web
address. e.g http://. Then, you run into the issue like you said where
the user has to do a little extra to see the images or spam filtering
may even reject these emails.. To be honest with you. I don't know if
there is a way around that. If there is, then I would certainly like
to know.

This is why most people resort to plain text emails since its the most
safe.
 
B

Bryan

I'm using Linked resources under 2.0 and I noticed a similar problem when
using embedded graphics, - these work OK within Outlook although they are
treated as YAhoo attachments..

Did you find any way around this issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top