1

I want to send an image (.JPG) through an XML file. How can I encode the image data in the XML file with help of XSLT file so that a user can see the image in Outlook? The image is not in a shared folder location; it is in my personal folder but the user should able to see image.

I have worked out and I got three ways to solve the problem:

  1. CDATA
  2. BASE64
  3. Just creating a URL reference to the image in the XML

I worked on CDATA and BASE64 but image is not coming out on the user's Outlook. So please help me work out how to get the image. How can I write code in XML or XSLT so that I can view the image? Is it possible?

David Webb
  • 190,537
  • 57
  • 313
  • 299

3 Answers3

0

If I understand your question correctly, you want to send an image in an email. If this is the case, then, AFAIK, you have two options:

  • send the image as an attachment to the email: in this case you may want to look at MIME

  • another option is sending an HTML email, in which the body of your email is essentially an HTML snipped: in this case you can put in the HTML a link (URL) to your image

In both cases I don't see how you can do this with XML/XSLT. Maybe you have some XML containing some data that you want to send by email, including the link to an image. If this is the case, then you can use XSLT to transform your input XML into (X)HTML and then use HTML e-mail.

MarcoS
  • 13,386
  • 7
  • 42
  • 63
  • Hi MarcoS, Thanks for reply....yes, you are right. Actually I have a software. I am working on this software. It takes xml and xslt file and convert into HTML (means user can see the text data in outlook). But it only converts text files.Now I want to add some image file/ path in xml file so that user can also see image in outlook. So I want to know how will I write a code for image data in xml or xslt ?? – Vikash Kumar Jul 18 '11 at 05:30
  • @Vikash: it depends on the input XML that you have: can you change it? does it have a DTD or an XML Schema? In the latter case, then you must check if/how the DTD/XML Schema let you insert an image. In the former case, you can basically do what you want, and the simplest thing is probably to add the same `img` tag that you would use in HTML, so that you just have to copy it with your XSLT. – MarcoS Jul 18 '11 at 05:47
  • Yes i can change the xml file. I have already used the img tag but it is not working. means If I will send a image in my outlook(email id) it will show because image is stored in my system but if I will send a image in ur email id it is not showing. it's problem. Actually I want to encode a image in xml file so that other user can see the image. Is it possible ?? – Vikash Kumar Jul 18 '11 at 06:10
  • I think not. If an `img` tag in HTML email does not show the image corresponding to link, it's probably because either the link is broken, or your email client is behind a proxy and it cannot reach the Internet to fetch the image from that link – MarcoS Jul 18 '11 at 06:58
  • yes, you are right. Can I solve the problem through BASE64 or CDATA ? Do u have any other idea to solve this problem ? please comment.. – Vikash Kumar Jul 18 '11 at 07:51
  • I think not. You probably have to properly configure the Outlook client to use the proxy – MarcoS Jul 18 '11 at 14:41
  • Thanks....but I have also a source code (in C#) of this s/w ....Can I use Base64 encoding ? I have worked on PDF file means I provided XML and XSLT file (as like input) in this s/w and got PDF file with image.But this code is not working for HTML. What's a reasion ? – Vikash Kumar Jul 19 '11 at 06:40
  • AFAIK, a software rendering HTML expects does not expect Base64-encoded images, so this is why it's not working for you. If you build an HTML email, then images must be provided as link to .gif, .jpg, etc files, as in any HTML Web page – MarcoS Jul 19 '11 at 08:39
0

I think you need more than XML/XSLT to do what you want. Perhaps this will help.

Community
  • 1
  • 1
Andrew Cowenhoven
  • 2,778
  • 22
  • 27
0

You could also try (using base64):

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />

or

in more custom using CSS (set height and width appr):

div.image {
  background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...);
}

Source

Robert de W
  • 316
  • 8
  • 24