none
Serializing EmailMessage object to byte array RRS feed

  • Question

  • I am using EWS Java API to fetch email message from Exchange Server. I am getting it as EmailMessage class instance. This class is defined in EWS Java API and it extends other EWS API classes as follows:


    Now I want to move those mails to ECM Documentum Content server without storing it locally. However the API for this server asks for ByteArrayOutputStream as a param to its import method. Thus I want to convert this EmailMessage object to ByteArrayOutputStream. But it seems that neither EmailObject nor any of its parent classes has implemented Serializable interface. So how can I serialize it to byte[] or to be precise to ByteArrayOutputStream?
    • Edited by Mahesha999 Tuesday, November 5, 2013 6:46 PM
    Friday, November 1, 2013 9:31 AM

All replies

  • Are both the Exchange Servers part of the Same Exchange Organization ? if so you should be using either the MoveItem or CopyItem operations http://msdn.microsoft.com/en-US/library/office/aa565781(v=exchg.140).aspx

     The EWS objects aren't meant to be used for storage or transfer of data and if you try to use them like you are you will have a number of problems as the objects won't contain all the Item's properties and the Item identifiers can't be reused.

    If your trying to Migrate email to a completely separate Exchange server organization then with EWS the two options would be to save the MIMEContent of the Message out and then reconstitute the Message at the Destination form the MimeContent.

    Or better if your running Exchange 2010 Sp1 of higher at both source and destination then you can use the ExportItems and UploadItems operation see http://msdn.microsoft.com/en-us/library/hh135142(v=EXCHG.140).aspx. These operations are superior as they allow you to maintain fidelity of all the properties on an item. 

    Cheers
    Glen

    Monday, November 4, 2013 6:04 AM
  • Found. I used the property

    byte[] EmailMessage.MimeContent.Content

    which returns mime content of the mail as a byte array. 


    Tuesday, December 17, 2013 7:47 AM