Modifying attachment filenames

Hi y’all

I’m writing a C Extmngr which hooks EM_SMTPMESSAGEACCEPT (EM_REG_BEFORE) events to do mail filtering and I’m having a really really hard time figuring out how to change the names of file attachments. Any and all help would be oh so greatly appreciated…

What I’ve done so far:

  1. Get the FILEOBJECT struct and the actual file data, reallocate the db storage to hold new contents, update the FO stuct’s FileSize and write everything back … works fine; one attachment icon (original filename), pointing to new content

  2. Change the filename part of FILEOBJECT (reallocating if necessary) … New gray icon with new filename appears pointing to new content, old icon with old filename points to a zero sized file (error if I try to view/save it)

  3. Change the MIME_PART that refers to the old filename to refer to the new one (change content-type and content-transfer-encoding too if necessary) … same as 2) except now both icons have the new filenames, and the original icon has a new encoding associated with it…

I’ve tried to completely dump each and every item in the note to a file, but I can’t see anything else relating to the attachments…

What am I missing?

Cheers and tia.

Subject: Modifying attachment filenames

I was under the impression that you are going to have to detach the file, delete the attached file (now that is detached), change the detached file’s name, and then attach the file back to the document.

Subject: RE: Modifying attachment filenames

This is an approach I have used sucessfully. HOWEVER, be aware that when you use the EmbedObject method, the attachments come back to the rich-text field (at the end) and without their application icon! I’ve not yet found a way to fix this, although it is only cosmetic; they still work (open, view…) in the normal way. Also remember that you can only make attachments to the back-end document and to refresh the front-end document you must save, close and re-open the document!

It’s never plain sailing, is it?