Prev: MSHFlexGrid not scrolling beyond 65,535 rows - see Q253211. Any fix?
Next: How to get the current column and line number of a text control
From: Michael Cole on 10 Jun 2010 20:58 Currently, we are receiving email feed into our application via POP3. What we would like to do is to view (and possibly work with) HTML emails, including those with embedded images, without having to save anything to disk, or any other "messy" operations. Reason being that some of our clients have restrictive disk access policies. Now from my understanding of HTML email, embedded images are actually attached files that are then referenced by a link in the email. To view in a HTML viewer, the image needs to be saved to disk somewhere. Is this correct, or can it be got around? Note that we would be happy to purchase a control that would assist in all of this, so I would accept commercial responses. -- Michael Cole
From: C. Kevin Provance on 10 Jun 2010 21:45 "Michael Cole" <invalid(a)microsoft.com> wrote in message news:hus1pt$2d9$1(a)speranza.aioe.org... : Currently, we are receiving email feed into our application via POP3. : What we would like to do is to view (and possibly work with) HTML : emails, including those with embedded images, without having to save : anything to disk, or any other "messy" operations. Reason being that : some of our clients have restrictive disk access policies. : : Now from my understanding of HTML email, embedded images are actually : attached files that are then referenced by a link in the email. To : view in a HTML viewer, the image needs to be saved to disk somewhere. : Is this correct, or can it be got around? : : Note that we would be happy to purchase a control that would assist in : all of this, so I would accept commercial responses. Well, I don't know if this is relevent, but the enbedded email images ive dealt with in the past were streamed data, meaning the bytes were embedded in the HTML with a binary tag. I would feed those bytes into a byte array and extract the image this way. If you cannot save that image to disk, you can feed it into a picture object and display it from there. I don't have that code handy at the moment, but could get it for you if you want it. - Kev
From: Michael Cole on 10 Jun 2010 23:18 C. Kevin Provance laid this down on his screen : > > "Michael Cole" <invalid(a)microsoft.com> wrote in message > news:hus1pt$2d9$1(a)speranza.aioe.org... >> Currently, we are receiving email feed into our application via POP3. >> What we would like to do is to view (and possibly work with) HTML >> emails, including those with embedded images, without having to save >> anything to disk, or any other "messy" operations. Reason being that >> some of our clients have restrictive disk access policies. >> >> Now from my understanding of HTML email, embedded images are actually >> attached files that are then referenced by a link in the email. To >> view in a HTML viewer, the image needs to be saved to disk somewhere. >> Is this correct, or can it be got around? >> >> Note that we would be happy to purchase a control that would assist in >> all of this, so I would accept commercial responses. > > Well, I don't know if this is relevent, but the enbedded email images ive > dealt with in the past were streamed data, meaning the bytes were embedded > in the HTML with a binary tag. I would feed those bytes into a byte array > and extract the image this way. If you cannot save that image to disk, you > can feed it into a picture object and display it from there. > > I don't have that code handy at the moment, but could get it for you if you > want it. > > - Kev What I currently have is as follows: - From the email component I am using (from ChillKat) I can get the email as HTML. This returns the HTML message, but has the image listed as: - <img height="154" width="218" src="cid:C9A46523-113D-4A09-AD4C-0B271B1476C5"> where I assume that the cid:C9A46523-113D-4A09-AD4C-0B271B1476C5 is a link to the image somewhere in the email. I can save this as a file on the disk, and open it up in a web browser, and it will display the email correctly, but with the image as the "square with cross" unavailable-type display. I can also get the email as plain text (no use) or as MIME, which is a long binary string that I don't understand. I can also get attachments to the message, but no attachments are listed. So the first issue is, how do I get the email with embedded images. I assume that it is in the MIME version, but I have no idea what to do with it. The second problem is the display. I wish to use the WebBrowser control, and just load the email into it as a document without having to save it on disk and then navigate to it. Again, I am having issues with doing this. If anyone can point me to a reference on this, it would be appreciated, because whilst I can create a new MSHTMLCtl.HTMLDocument document and load the HTML, I can't get that into the WebBrowser control. It may even be that if I need to get the email in a different format, then I will not be able to use the WebBrowser control to display it. Any assistance would be appreciated, as the boss is screaming. -- Michael Cole
From: Mayayana on 10 Jun 2010 23:25 You should find that the IMG tag in the HTML has been altered from: <IMG SRC="pic.gif"> to something like <IMG SRC=3D"cid:LONGRANDOMIDSTRING"> You then look for that ID. There are boundary marker codes involved that you can look into. They delineate the parts of the email body. But you don't really need to deal with those just to find the image. (But note that not all images are embedded. They can also be remote-linked.) Below the body of the email you should find something like the following: Content-Type: image/gif; name="pic.gif" Content-Transfer-Encoding: base64 Content-ID: <LONGRANDOMIDSTRING> The CONTENT-ID line will match up with the IMG SRC ID string. Following that is a single line space, then base64 encoding starts after that. This base64 code is the entire file, which can be saved to disk as-is. You don't need to write a header, etc. You can find Base64 decoding routines here: http://www.xbeat.net/vbspeed/c_Base64Dec.htm Watch out for carriage returns. Email is usually formatted with a carriage return every 76 characters, but those have to be stripped out before converting Base64 back to bytes. Also watch out that you don't pick up spaces, etc, when you retrieve the Base64. If you don't get exactly the Base64 content the entire decoding will be corrupted, not just a single byte. That's because 4 Base64 characters translates to 3 bytes. So if you start at the wrong byte then every group of 4 will be wrong. Also watch out for escape character formatting. = will actually be rendered as =3D in the body of the HTML. (As shown in the sample above.) | Currently, we are receiving email feed into our application via POP3. | What we would like to do is to view (and possibly work with) HTML | emails, including those with embedded images, without having to save | anything to disk, or any other "messy" operations. Reason being that | some of our clients have restrictive disk access policies. | | Now from my understanding of HTML email, embedded images are actually | attached files that are then referenced by a link in the email. To | view in a HTML viewer, the image needs to be saved to disk somewhere. | Is this correct, or can it be got around? | | Note that we would be happy to purchase a control that would assist in | all of this, so I would accept commercial responses. | | -- | Michael Cole | |
From: Mayayana on 10 Jun 2010 23:43
In addition to what I wrote in my first post, you might find this useful: www.jsware.net/jsware/vbcode.php5#mail There's a file in that download that provides an explanation of MIME structure for various email types. It's fairly simple, just not well documented. From my first post you can deduce how to get the embedded images and build a webpage view: Use the boundary markers to find the HTML content. Clean up the escape characters, etc. Find the IMG CID IDs and decode the corresponding Base64 blocks. Write the base64 to disk with file names and patch the image tags accordingly. Then write your HTML file to disk and load it. In other words, where you have: <IMG SRC=3D"xxxxxxxxxxxxx"> ...... Content-Type: image/gif; name="pic.gif" Content-Transfer-Encoding: base64 Content-ID: <xxxxxxxxxxxxx> you'll need to decode the base64, write it to disk as pic.gif, and repair the IMG tag to read <IMG SRC="pic.gif"> |