Copy link to clipboard
Copied
Hi
If I wanted to create a Word document or an Excel file, I would simply use cfcontent and then save the content to disk using cffile.
However, I now have a requirement whereby I would like to create a .MSG file. (This is the equivalent, if you use MS Outlook, of saving an email that you have in your inbox to disc.)
My question is, how do you accomplish this?
I was thinking I could change the MIME type of the document to a type equivalent to MS outlook message files but how do include the attachments etc to the email?
Has anyone done something similar before? Ideas please?
Thanks
Michael
Copy link to clipboard
Copied
Changing the MIME type of a response doesn't magically convert the file format of the response, it just sets an HTTP header to reflect the desired MIME type. What the browser does with that info is up to the browser, but when you save the file, it's still just plain text, unless you have specifically created the binary data that represents the file format you want (which it doesn't sound like you're doing).
So simply using CFCONTENT to indicate the MIME type is application/msword (etc) and saving downloaded data as a .doc file does not make it a Word file, unless the data you send down is in the Word binary format. It's just a text file with a .doc extension. Word will have a stab at converting it to Word format - in memory - when you open it, but until you resave it, the file is still just text.
The same applies to any other file format. If you want to create an Outlook message file with attachments etc, you'll need to file the file format somewhere (and it's like to be proprietry, and not published, if it's a MS format), and replicate that. No mean task.
Why are you trying to create a file representing a saved email message? It's an uncommon requirement...
--
Adam
Copy link to clipboard
Copied
Thanks Adam for your response.
My issue is that we have an internal document management system and users currently send emails and then save and store them in the document management system as if they were documents.
In my new application, we would like to automatically generate and send these emails and at the same time store them in the document management system - to reduce the number of steps the user takes to perform this action.
So I guess we might have to get the user to do some stuff manually.
Thanks again for your help.
Michael
Copy link to clipboard
Copied
Is it important to use the .MSG format for these files? If not you might try generating the document content as HTML then use that HTML as the body of an email and store it in your document managment system.
Copy link to clipboard
Copied
To handle attachments you could use MIME HTML when storing the document.
http://en.wikipedia.org/wiki/MHTML