Friday, September 05, 2008

Embed Image in CRM 4.0 templates

In my current engagement, there was a requirement to embed images in email template. Now, as it is very well known that you can easily achieve it by copy pasting the HTML to CRM's Rich Text Editor. Most of the times it works fine. But then if it goes normal all the times I won't have to blog about it right? so.. here it goes..

In our case, we had a sample word document which had an image on top and some formatted text. As soon as this came to me, I fired up CRM's web UI and created a blank template. I created an HTML file out of word document. After opening the html file and copying/pasting, it worked fine and template got saved without any issue. Once the template was in place, I tried to apply it to an email activity. It worked fine, I could see the formatted text, the image on top and the layout was also preserved. Happily I clicked on Save button and.... whoooooshhh... it was gone.. the image was gone, everything else was there, but the image was gone. So there I was, the only thing I needed to close today to have a nice weekend was this email template fix. Also one of my colleague was working on this and he did a lot of research eliminating many other possibilities why it won't work. After few more minutes, I made a blank html page, added a nice Windows Live Logo and repeated the copy/paste on the same email template. Once it was done, I applied to the same email and voila.. it worked. So it was pretty clear that it was all due to the HTML that we were using for the template.

I always keep IE Dev Toolbar available, so I fired it up, and clicked on Validate -> HTML. The online HTML validator showed me there were some minor issues with the HTML. I corrected them and removed word HTML tags in which my IMG tag was wrapped. After this I followed the process copy/paste and test and .. there it was a .. working email template with an image.

Also it was very clear that we will have to find out a structured process to do it as there will be more templates coming soon. I might come up with an automation process, if you are interested keep watching this blog or drop me an email, if you need it urgently.
Update : This trick also works with KB Article. Just copy and paste from any Web Page to get images in your KB Article. However, it doesn't work with notes. Notes doesn't have Rich Text capabilities.

13 comments:

Anonymous said...

Thanks a lot for the post.
I'm still with this issue and I don't know how to fix it up.
I'm trying to attach an image stored in our web server with an url like this htt://www.xxxx.com/xxx.jpeg but when I save the mail or try to send it the image still dissapear.

What I'm doing wrong?

Chinmay said...

Hi Jose M,

I would suggest you to have a simple, valid HTML page that contains only image tag which points to the image on your server and then copy-paste it to CRM template. It should work fine. If it does not, I suggest you to zip your HTML fiel, Upload it to skydrive and send me the link so I can download and have a look.

I strongly feel that a valid HTML block should solve your problem. For best results, go old school, i.e. use notepad and write your HTML tags on your own. Let's see how it goes.

-------
Chinmay

Anonymous said...

Hi Chinmay.

I don't know what happend with the previous message ;-)
If repeated sorry.

Well, I have created a html page that I have uploaded to :

http://cid-00ca80ea265dd283.skydrive.live.com/browse.aspx/.Public?uc=1&lc=3082

I have copied and pasted into the template and everything went well.
But, when I add the template to the mail and try to send or save the behaviour is still the same.

Do you see something wrong in the page code?
What do you think is happening?

Thanks in advance.

Chinmay said...

Hi Jose M,

I used the HTML file and created my own email template and it is working absolutely fine.

Here are the steps I followed :
1. I opened your HTML file in Internet Explorer.[In IE I trust... all others are useless.]
2. CTRL + A and CTRL + C.
3. Created a new template and then put in necessary details. and in Template body area, I did CTRL + V.
4. Once the template was ready, I save it. If it saves the template with image it WILL come in your email so after you save the template, I suggest you close it and open it again. If the image is there, I dont see why it won't come when you create an email using the template.

Hope this helps.
----------
Chinmay

Jaka said...

Hi Chinmay,
I came across your blog when trying to figure out if we could have a rich text format on CRM 4.0. What we would like to have is a rich text format embedded in Note section. Do you know if it's possible?
Thanks

Chinmay said...

Hi Jaka,

It is not possible with Notes as Notes doesn't have Rich Text capabilities.[I am not sure how, but maybe some unsupported customization might help you here.] I've updated the blog with these information.

Regards,
Chinmay

Jony Lawrence said...

Wonderful!!!

Unknown said...

is there any way to have a rich html editor for email or other html crm fields? the cut&paste way it's not very much appreciated by end users

Chinmay said...

Hi L,

It depends, where exactly you need html editor?

Unknown said...

for example in the email form, to add links, images w/out cust&Pastw from an external web page. the email editor ir very poor as html editor.

Chinmay said...

Hi L,

It is not possible to do in a supported manner and too much hassle even for an unsupported customization. You might want to provide this feedback to CRM Product team via http://connect.microsoft.com, they DO listen to the end user feedback.

Regards,
Chinmay

Unknown said...

Im in the same Boat. I validated the html code and it found no errors. I copied it from IE to the template. Saved it and it saved fine. I attach the template to the email to a (test) lead and it shows up. BUT.. If I right click the picture and do a properties the picture disapears. The prop. box comes up and even has the URL as being correct. But it still disapears and doesnt come back. This also happens if I just save the email and not send it.

What gets me is it worked for me once. I changed the photo by changing the html code and resaved the file. And did the whole process over. And now it doesnt work.

HELP. :)

Chinmay said...

Hi Dusty,

I've alwasy seen this method working flawless, so to start with how about trying with some simple HTML? Say a paragraph and a simple image in it.

Let me know if it works for you, and if it doesn't send me the HTML you are using, will check it out for any errors.

Regards,
Chinmay