views:

342

answers:

2

I'm using embedded web browser from Bsalsa to write an email client in Delphi

I have a problem with cid embedded attachments such as:

<IMG src="cid:5D4219C71EAE43B1864AE9CB27C224A8@somehost">

I store the attachments in the database but can't figure out how to provide them to the browser. It seems custom moniker might need to be implemented but the documentation is scarce.

Any help would be appreciated.

A: 

The simplest solution is to extract your "attachments" as requested into a temporary folder, then change the reference in the source to point to these temporary files, prior to being displayed. In the past I have used diHTMLParser to just this with great success.

If I remember correctly, the message contains these mime attachments along with an optional filename which doesn't always exist, but will have a mime type so you might have to have a translation table to get a default file extension for an attachment. Also, keep track of the files you place in your temp directory and clean up once your message window is closed. If you allow multiple messages opened at once, allow for name collisions and generate unique files.. it is common for signatures to have the same name, but be from different people... can be confusing if your message from John is signed Mary. :)

skamradt
Right, that's what I'm currently doing, but was hoping for a "proper" solution
Daniel Maurić
in my opinion, the moniker approach feels like using a sledgehammer to pound a tack into balsa wood. It works, but takes more effort when you can just use your fingers.
skamradt
Well, in theory monikers are the proper solution, much less of a hack than saving to temp files etc, it's only the complex implementation that is the problem, IMHO
Daniel Maurić
+1  A: 

I've implemented it using a "pluggable protocol" handler and it's easier thant it looks. Start here: http://msdn.microsoft.com/en-us/library/aa767916%28VS.85%29.aspx and here: http://www.bsalsa.com/protocols.html

I am sorry I can't share the code I wrote but it's written for the company I work for and I have restrictions about it. Basically you need a com object that implements the proper interface to get the data and allow the web browser control read them.

That's IMHO the correct way to do it - altering the mail and storing temporary data may bring issue in the long run.

ldsandon