Hello guys...
I have written a program which uses templates prepared in HTML to send emails.
Everything was working in OUTLOOK 2003/2007 but now 2013 is a standard in my company.
The problem is that OUTLOOK 2013 does not accept <img>link</img> anymore.

My program open html template and read it line by line and add it to email body.
Everything is ok beside lack of pictures (even there is no red cross in place of picture - just nothing)

what I use to put html to email body:

newMail.HTMLBody += line; 
* LINE = line of html code taken from file *

example of html code taken from one of the templates:

<img src="S:\08 EU HD\06 Tools\09 Notifier\CONFIG\TEMPLATES\GFX\unplan1.png" width="592" height="74" />

Can you help me to fix this?
thx!

Recommended Answers

All 14 Replies

My corporate emails still use <img> tags and they show fine in my Outlook 2013.

You can use img tags fine in Outlook but remember a couple of things:

  1. You can't direct it to something on your local drive/network. Outlook doesn't make a copy of your picture, the img tag is simply a reference to where it is. If the target machine can't find the location, it won't display.
  2. Some clients disable the downloading of images to prevent spam. This was implemented because some spam mailers would use the image download to verify they'd reached an active address.

Given the URI in your image tag looks like a network drive, thae target machine would have to have the same location mapped to the same drive letter on their machine for this to work (#1). If they can navigate to the file in Windows Explorer, it may be that their client doesn't accept you as a trusted sender and refuses to automatically download the images (#2)

Yep but It was working fine on office 2003/2007/2010.
All computer using that program have all mapped shared drive as it is.
I have tried to change the paths to something different. the same problem.

BTW...My program does not send email aoutmaticaly.
It just opens the template in outlook ...THen user has to click send.
Outlook 2010 was always loading img from the reference in <img> tags.
What should I change to make it happen on 2013?

Did you ensure that you set IsBodyHtml to true?

Will check that - thanks for the clue :)

I have no "ISbodyHTML" at all...But it works as html...styles/rest the code works like a charm.

code begins with:

                Outlook.Application oApp = new Outlook.Application();
                Outlook.MailItem newMail = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
                newMail.SentOnBehalfOfName = FROM;
                newMail.To = RecipientBox.Text;
                newMail.CC = relate_cc();
                newMail.Subject = SUBJECT_WHOLE();
                newMail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
                newMail.Display(false);`

Ah you're using an outlook mailitem. You're probably going to have to embed the image as a resource in the email.

Unfortunately I have no knowledge of office interop so I can't help you any further than this.

I cannot do that :(
biggest adventage of my program is that its universal...SO I have to use html templates with all html possibilites.

But I heared something about word.inspector which is used by outlook
can anybody give me some hints how to paste my html into outlook with word.inspector?

Maybe you're approaching this from the wrong angle. Is there any particular reason that you have to use the Outlook client? Would it be possible to just connect to the Exchange/SMTP server and send the mail directly from your software? This would be, by far, the easiest approach in my opinion.

Using the Office interop for this just seems like using a hammer instead of a screwdriver to fix a screw...

Yes but I want user to be able to preview the generated email - until he clicks on send button :/.
THe worst thing is that it was workin in all previous outlook versions....

As the e-mail is written in HTML, you could use the built in browser control to offer a preview in your form before they send the mail. Although this does make it more complicated I admit...

I make some experiments woth word inspector.
But I cannot paste the content to htmlBody - can you help me?

Outlook.Inspector inspector = newMail.GetInspector;
Word.Document document = (Word.Document)inspector.WordEditor;
document.Application.Selection.InsertFile(templateENG);
document.Application.Selection.Copy();

how to paste the content to htmlBody?

Ok I have managed to use word.inspector to paste html into outlook.
It works OK, but the main issue now is that it does not recognize styles in this html....So everything is not formatted correctly.

Outlook.Inspector inspector = newMail.GetInspector;
                Word.Document document = (Word.Document)inspector.WordEditor;              
                object missing = System.Type.Missing;
                object attachment = false;
                document.Application.Selection.InsertFile(templateENG, ref missing, ref missing, ref missing, ref attachment);`

any idea how to fix this, or maybe there is another possibility to put html code into email?

Anyone wants to share the knowledge with me? :)
thx

Be a part of the DaniWeb community

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