none
EWSJavaAPI_1.2: Fetching Mime content of a message which is attached to another message. RRS feed

  • Question

  • Hi 

    I like to get Mime content of a attachment which is an email. I want to save that attachment as eml file format. Below funcation fails at  { att.load(EmailMessageSchema.MimeContent); }. error is Cannot cast PropertySet to PropertyDefinitionBase.. Any ideas how to fetch that data?


    AttachmentCollection attachmentsCol = emsg.getAttachments(); 
    for (int i = 0; i < attachmentsCol.getCount(); i++) {
     
    if(attachmentsCol.getPropertyAtIndex(i) instanceof FileAttachment){
    FileAttachment attachment=(FileAttachment)attachmentsCol.getPropertyAtIndex(i);
     
    if(attachment.getId().equals(id)){
    fileType=attachment.getName().substring(attachment.getName().lastIndexOf("."));
    attachment.load(name+fileType);
    }
    }else if(attachmentsCol.getPropertyAtIndex(i) instanceof ItemAttachment){
    ItemAttachment att = (ItemAttachment) attachmentsCol.getPropertyAtIndex(i);
    if(att.getId().equals(id)){
    fileType =Constant.ECM_EXCHANGE_FORMAT;
    //'addProp.add(new PropertySet(EmailMessageSchema.MimeContent));
    att.load(EmailMessageSchema.MimeContent);
    MimeContent mc =att.getItem().getMimeContent();


    }
    }

    }


    Thursday, April 24, 2014 6:39 PM

All replies

  • You should just be able to use a normal propertyset (the error looks like its saying your trying to add a propertyset to a propertySet which you wouldn't be valid) eg something simple like this should work okay

    PropertySet psPropSeta = new PropertySet(BasePropertySet.FirstClassProperties) { ItemSchema.MimeContent };
    att.load(psPropSeta);
    
    Cheers
    Glen
    Friday, April 25, 2014 7:14 AM