I have a small problem, maybe you guys know how to avoid it.

                system.IO.StreamReader text = new System.IO.StreamReader(to the html path);
                while ((line = text.ReadLine()) != null)
                     newMail.HTMLBody += line

When I open html file directly from its folder where html file is,byclicking 2 times on it, All images are opened correctly, because browsers (like IE) threats a folder with the html as a root folder.

The problem appears when I try to put some html into outlook with code above.
Outlook doesn't know that images are in other root folder with html file, so it doesn't open them...I need to modify the html code and and a whole path to any image file in it.
for example - it doesn't work:

<img src="logo.jpg" width="700" height="118" alt="Logo" longdesc="Logo" /></p>

That one works:

<img src="d:\htmls\web1\logo.jpg" width="700" height="118" alt="Logo" longdesc="Logo" /></p>

And the question is.
How to make my program think that path to html, its also path to all images used in that html?
To make it think like IE - you open html file somewhere, and IE knows that img files are also at the same dir with html file.

Thank you in advance!.

Recommended Answers

All 2 Replies

For HTML emails the images always need to be used with an absolute path. src="image1.jpg" means nothing when the code is away from your development environment. You will need to host the images on a server and point to them with a full address.
This link will help you: http://kb.mailchimp.com/article/top-html-email-coding-mistakes

So full path is the only way? :)
ok..its not a big deal :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.