Package com.aspose.email

Examples of com.aspose.email.Attachment


MailMessage message = MailMessage.load("data/message.msg", MessageFormat.getMsg());

System.out.println("Extracting attachments....");
for (int i = 0; i < message.getAttachments().size(); i++)
{
    Attachment att = (Attachment) message.getAttachments().get_Item(i);
    System.out.println("Attachment Name: " + att.getName());

    // Get the name of attachment. If msg subject contains characters like :, /, \ etc., replace with space
    // because windows cannot save files with these characters
    // also save first 50 characters as file name to avoid long file names
    String attFileName = att.getName().replace(".eml", "").replace(":", " ").replace("\\", " ").replace("/", " ").replace("?", "");
    if (attFileName.length() > 50)
    {
        attFileName = attFileName.substring(0, 50);
    }

    // Save the attachment to disk
    att.save("data/" + attFileName);
}
      System.out.println("Done ...");
  }
View Full Code Here

TOP

Related Classes of com.aspose.email.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.