Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Marking EML files generated with JavaMail as "X-Unsent"

843834Jul 11 2010
Hi all!

I know this question has been asked several times, and every time the forum community seems to get closer to answer when suddenly someone decides to lock the thread because it's become to old. I'm hoping my question is specific enough to alleviate this a little bit.

I have the (common, it seems) desire to have my Java application launch the user's default e-mail client, supplied with a default subject, message and attachment, such that the user can modify the subject and message, input the "to" address, and ultimately send the message. The following solutions have been recommended, with the listed limitations:
mailto protocol (does not support attachments)
JavaMail (requires that the mail client be part of the application; for this particular application the user's default e-mail client must be used

The solution I have developed does the following
- Generate the e-mail outline using JavaMail as a MIME-encoded message
- Attach the file to the MIME message
- Save the message to a temporary file on the user's computer with the .EML extension
- Open a file writer to the .EML file which writes the line "X-Unsent: 1" at the beginning of the message
- Launch the e-mail client with JDesktop.open, passing the EML file as a parameter

This seemed to work great on Outlook Express, Windows Mail, Windows Live Mail, etc. However, Microsoft Outlook does not natively support EML files. I have now added an install-time option for the user to select that Outlook is their default client, which executes a script to modify the user's registry to allow them to launch EML files with Outlook.exe (requires the /eml command line switch). Now, once again, things seemed to be going well.

However, Outlook apparently does not support the "X-Unsent: 1" line I have added to the file, as it loads the MIME message (with attachment, message, etc.) as though it were a received message (i.e. there is no sent button). My beta testers are currently using the "Forward" button to get around this, and I've discovered that pressing Alt+S (the keyboard shortcut for sending) still works, even if the send button doesn't appear.

Is there another way to specify in the file that it is in draft form, and should be opened in an editable format by Outlook? Am I going completely the wrong way with using .EML files if I want to support Outlook?

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2010
Added on Jul 11 2010
0 comments
1,180 views