Error in opening draft email saved with msg extension

I am attempting to create a email and save it on local hard disc. The email is a file having msg extension. So that it can be opened with MS Outlook. Also I want it to be in DRAFT mode. Like we can create draft email with MS Outlook. This message will have multiple attachmets.
Thus when user opens this file, it will get opened with MS Outlook and user will be able to edit the message text, TO/CC list, attachments.
I am using MimeMessage.writeTo(Outstream) API to save the message to a file, say C:\test.msg
But if I double click test.msg in explorer to open it, it gives error:
Can't open file C:\test.msg. The file may not exist, you may not have permissions to open it, or it may be open in another program.
Is it possible to create draft Outlook email message with msg extension?
If yes, how?
My code:
               Properties props = new Properties();
               props.load(new FileInputStream("C:/email.settings.properties"));
               // create some properties and get the default Session
               Session session = Session.getDefaultInstance(props);
               session.setDebug(debug);
               // create a message
               msg = new MimeMessage(session);
               //Create message from saved email
               File savedFile = new File("C:/test.msg");
               // set the from and to address
               InternetAddress addressFrom = new InternetAddress(from);
               msg.setFrom(addressFrom);
               InternetAddress[] addressTo = null;
               addressTo = new InternetAddress[recipients.length];
               for (int i = 0; i < recipients.length; i++) {
                    addressTo[i] = new InternetAddress(recipients);
               msg.setRecipients(Message.RecipientType.TO, addressTo);
               // Setting the Subject and Content Type
               msg.setSubject(subject);
               msg.setContent(message, "text/plain");
               MimeBodyPart attachmentBodyPart = new MimeBodyPart();
               DataSource ds = new FileDataSource("C:/WhichSQLServer.pdf");
               attachmentBodyPart.setDataHandler(new DataHandler(ds));
               attachmentBodyPart.setFileName("WhichSQLServer.pdf");
               Multipart multipart = new MimeMultipart();
               multipart.addBodyPart(attachmentBodyPart);
               msg.setContent(multipart);
               //msg.setFlag(Flags.Flag.DRAFT, true);
               msg.getFlags().add(Flags.Flag.DRAFT);
               msg.setFileName("test.msg");
               msg.saveChanges();
               FileOutputStream os = new FileOutputStream("C:/test.msg");
               msg.writeTo(os);
               os.flush();
               os.close();

Outlook Msg files aren't as easy to write as you would believe. They are a propretary format that microsoft uses based on the DocFile format that Word and Excel uses.
If you did the MimeMessage.writeTo(out) and saved it to a .eml file Outlook Express will open it, but Outlook doesn't directly read this file type.
I've started on a library to allow the creation of Outlook msg files, right now it only allows you to set text, dates, long, and boolean values on the email message (which means you can set stuff like the recieved date/time, subject, body, to, from, etc), but it does not yet support attachments or extra recipents (CC, BCC, etc). I'll be updating the copy on my site as soon as I get the other stuff working (which isn't as easy as it sounds).
Priasoft has a library available that can do what you want however.
travis (at) overwrittenstack.com

Similar Messages

  • Sending and saving mail message with .msg extension

    How can I save the mail message when sending with .msg extension , so that when user click on the saved message it will open in OutLook Express. ?

    I already tried the one u suggest , MimeMessage has a method
    writeTo(OutputStream) which can be used to save the message with .msg extension .... But the main problem arises when trying to open it in OutLook .....
    It gives some error .... I think that it may be because of format .. .msg has binary format while MimeMessage is in another format ....
    is there any way to convert MimeMessage to binary and then save it in .msg file .

  • If I open my email server with firefox the autocomplete doesn't work. why?

    If I open my email server with Internet explorer I don't have this problem

    Thank you Alley!
    But still not working.
    I've just bought my Apple TV. I think it is impossible low battery and I tried to hold menu and left, but it didn't response again.
    When I press any buttom, the Apple TV LED doesn't flick. The light is just on... not flickering...
    Thanks again!
    Igor

  • Open Default Email Editor with attachment

    How I open default email editor with attachment. Now I can just open the email editor with mailto,subject,body BUT i cant open it with a attachment, which is in a server.

    es5f2000 wrote:Please don't resurrect zombie threads for "me too" style posts.Hmm, I didnt know this was wrong..
    es5f2000 wrote:If you can use 1.6, Desktop.mail() will at least open the mail application, though it won't let you auto-attach. If you must use 1.5, you may have to hand-roll a solution for each environment you support. I'm not personally aware of any 1.5-compliant library that provides this functionality.Since youve replied, the 1.6 solution of opening an email but without an attachment is not good much use to me, and the creation of various support files and putting them into an attachment is the part of the process that the user has most problems with. So either I could either just create the attachment somewhere and let the customer handle the whole email side of things OR I could make use of the fact that my customers email address is embedded in their license and that an smtp server can be used to send an email from anyone, to open a form for the user to write a problem description and then send it from within my application, but the trouble with this approach is they can't have full control over the email they send.

  • How can I open my old documents with cwk extension?

    how can I open my old documents with cwk extension?

    Pages '09 may open it. otherwise try LibreOffice [free].
    Peter

  • Error when opening a BW query with Crystal Reports

    Hi all,
    I am having problems when opening a BW query with Crystal Reports, the strange thing is that it only happens with
    the bo user I have created. If I use a user that already exists and that has SAP_ALL authorization it works.
    I don't know if this could be an authorizations issue, but I have created a role with all the authorizations stated in the manual.
    The error I am getting is the following:
    "An error occurred while generating a new report template. Error in UNKNOWN.RPT file"
    Does anyone know what this could be?
    Thanks

    Well,
    I cannot access the system now. But I think it is not an issue of authorization, because I assigned all the good user's role to the bo user,
    and even with that, it still don't work.
    Thanks

  • Cannot open doc perviously saved with pages v5.0. Message states need latest version which I have!

    Having created a new document using latest Pages ,v 5.0 (downloaded when I upgraded from Mountain Lion to OSX Mavericks) and saved it, when I try to open it, I get a message, " You need a newer version of Pages to open this document." The strange thing is that all my other previous docs created using iWorks , Pages, version 09, open successfully when I double click on them, although they now contain the "improvements" introduced by the upgrade to latest version of Pages. Can anyone suggest why new docs cannot open when created recently with the latest version.

    Pages 5.0 is indeed the latest version, but are you sure you're using Pages 5.0 to open the document?
    The Pages icon should look like this:
    If it doesn't, you're actually using an older version of Pages to open the document.  This is quite possible, because the Pages update didn't always place the new icon in your dock.
    If the new icon is not in your dock, find it in your Applications folder and drag it there.  You can drag the old one off your dock as well.

  • How to allow attachments on forms saved with Reader Extensions?

    I have a Livecycle developed form that includes action builder buttons to attach other documents.  When I re-save the form with 'Reader Extensions', the attach buttons no longer work.  Is there a way to allow this functionality?  How?
    Thanks.

    Of course. This facility is only available with Reader extension server.  You need to apply reader Extension permissions for the form and specifically , you need to add Embedded File Attachments reader extension.

  • HTML Email saved as MSG opens as RTF Email when Exchange Cached mode is OFF

    Hello,
    i have the following problem:
    In an Exchange 2013 environment each time i open a HTML email and save it to disk as a MSG file (Unicode or non Unicode) i get a MSG file with an RTF Body. This only happens when Exchange Cached mode is turend OFF. I tested this with Outlook 2010 and Outlook
    2013 with no 3rd Party Addins installed. Any idea?
    Regards
    Thorsten
    Best Regards/Viele Grüße Thorsten

    I've found this information from our internal channel.
    In some case, when you need to convert MIME e-mail with HTML body into .MSG file. For that, HTML must be converted into RTF.
    Outlook Converter provides basic means of such conversion (which can be suitable in most cases), and lets you use any external converter for high-quality HTML-to-RTF conversion. Although Outlook can display .MSG files which have HTML
    body and no RTF body, the problem occurs when you try to forward or reply such e-mail. For this to succeed, the original message must have RTF body as well.
    So, please check whether the message you've dragged onto desktop is MIME message. This might be the root, however, it
    still doesn't explain why it only occurs in specific circumstances (Exchange online mode only).
    Feel free to post back. Thanks.
    Cheers,
    Tony Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact
    [email protected]

  • Acrobat error when opening pdf email attachments

    I have a user who has the latest version of Adobe Acrobat and Reader installed on his PC running Windows 7 Pro SP1 which is up to date on patches.
    He was unable to open any pdf documents attached to email and was getting an error from Acrobat saying it couldn't open them. I changed the default file association for .pdf file from Acrobat to Reader and now he can open most pdf attachments. The only ones he is having a problem with are ones that come from his bank in what he was told by his banker are secure emails.
    What happens when he clicks on the pdf attachment in the emails from his bank is that he gets a popup with Adobe Acrobat in the title bar of the popup and the message that says "Cannot use Adobe Reader to view PDF in your web browser. Reader will now exit. Please exit your browser and try again." The buttons to click on are OK and Cancel. If he clicks OK, the popup goes away and the pdf then opens in Reader.
    So while he can view the pdf, he gets the annoying popup that he has to click through. Is there any way to get rid of that error message popup so when he clicks on the pdf in the secure emails, that it just opens without error like the pdf's do from non-secure emails?
    Jonathan

    Post your question in the forum for Adobe Reader.

  • Adobe reader error when openning an email attachment on ipad.

    I can not open Adobe documents sent via email on my iPad since upgrading the app. This is the message:
    Please wait... If this message is not eventually replaced by the proper contents of the document, your PDF viewer may not be able to display this type of document. You can upgrade to the latest version of Adobe Reader for Windows®, Mac, or Linux® by visiting  http://www.adobe.com/go/reader_download. For more assistance with Adobe Reader visit  http://www.adobe.com/go/acrreader. Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or other countries. Mac is a trademark of Apple Inc., registered in the United States and other countries. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.

    Your PDF document is a special type of form called a "dynamic XFA form".
    Currently, Adobe Reader mobile products (for iOS, Android, Windows Phone) do not support static or dynamic XFA forms that are created with Adobe LiveCycle Designer.  (This is not a new problem, however.)
    The message "Please wait..." is displayed when a dynamic content is not supported by a PDF viewer.
    Please use the desktop version of Adobe Reader on a Windows or Mac computer to fill out XFA forms.
    Sorry for the inconvenience.

  • Unable to open HTML documents saved with Firefox 3.0.6

    After downloading complete web pages using Firefox, I am unable to open the html document using Firefox in Linux (it is no problem with Opera). I consistently receive this Firefox error message:
    File Not Found
    The file /home/richard/Documents/ . . . cannot be found. Please check the location and try again.
    * Could the item have been renamed, removed, or relocated?
    * Is there a spelling, capitalisation, or other typographical error in the address?
    * Do you have sufficient access permissions to the requested item?

    Next you give Steve Jobs more money as he intended.

  • Error when opening, via email, files from PC computers

    Whenever I receive a file through email from another person who has created the file on a PC (i.e., a Word or Adobe Acrobat file), the file won't open and I receive this message:
    "Word (or other application, adobe, etc.) cannot open this document. The document might be in use or might not be a valid Word document."
    I do know that the files aren't corrupted because they do open successfully when I open them on a PC.
    What do I do to solve this problem?
    Thanks.

    Welcome to the discussions!
    You can always ctrl-click the document and choose Get Info > Open with > ( Choose from the dropping menu or assign ) the application you want.

  • Is there a program that will let me open  AOL email saved in Mac OSX 10.4.7? I am now running Mountain Lion

    I have a 27"  iMac runnung Mountain Lion. When I try to opem my AOL email files saved in OSX 10.4.11 on a 20" iMacG5, I get a message saying "You cannot open the application 'America Online' because the Classic environment is no longer supported." Are there any programs out there which could convert these files so that I can use them? Thank goodness I still have my old computer for now.

    Connect the new hybrid drive to your MBP.  Start up your MBP holding the OPTION key, the two HDD icons will appear.  Select the 'restore' icon on the right.  When you get to the menu where you have 4 options, select Disk Utility.  Format the drive and then you can use the option of restoring it from Time Machine.
    Ciao.

  • How do I send draft emails saved in Outlook?

    My iPhone is synched with Outlook on my computer at work. If I compose an email on my work computer and save it as a draft, it appears on my iPhone in my "Outlook" drafts folder, but does not give me the option of sending it or editing it from the iPhone. It does not appear in the iPhone's "Drafts" folder -- and I cannot move the message into the iPhone's (local?) "Drafts" folder.
    Does anyone have advice as to how I can compose an email and save it as a draft on Outlook on my computer at work -- and then later continue to work on it and send it from my iPhone?
    Thanks!

    You're welcome.
    If the account an Exchange account, or an IMAP account?
    If an IMAP account, you should have an Advanced selection with a Mailbox Behaviors selection for storing the account's Drafts, Sent, and Deleted mailboxes on the server or locally on the iPhone.
    I don't access an Exchange account, so I don't know if the same is available with an Exchange account or where the selection is located with the account settings.

Maybe you are looking for

  • Find the place where a object  is stored ?

    hi all, can someone tell me how to find out a object ,e.g : a index , object_id is 1000 then ,how to find where it is placed or which datafile ? thanks you!

  • How to create a border around an AP DIV

    Can anyone tell me how to do this? Seems like a simple request - hopefully it is! Also, how do I change the border color? Thanks!

  • Invoke the image selecting thing in Address Book on regular images?

    When you select an image in Address Book, there's this button that allows you to put the image through filters. There's a similar thing in Adium, so I'm assuming it's some sort of thing that can be called at will by osx. Is there a way to do this on

  • How to create the return delivery in MM

    Hi, Please let me know the detailed steps as to how to create the breturn delivery for the Po in MM with reference to Advanced shipping notification in sus. Our ins MM-XI-SUS scenario. thanks, Manu

  • Hidding Views in Dashboard Section

    Hi, Can anybody please help me on this The requirement is to do a dynamic dashboard where I want to hide some views in section. Iam doing a Top 10 customers by Revenue for US , EU , AP regions. and I gave a dashhboard page prompt as "REGION" for US ,