Analisi dei file di messaggi Microsoft Outlook

Contents
[ ]

Con Aspose.Email, è possibile analizzare i messaggi Microsoft Outlook con poche righe di codice. Questo articolo mostra come fare. Aspose.Email dispone di classi per eseguire molte operazioni di programmazione con i messaggi Outlook. L’esempio di codice sottostante mostra come:

  1. Carica un messaggio email.
  2. Ottieni l’oggetto dell’email.
  3. Ottieni il nome del mittente.
  4. Ottieni il corpo completo del messaggio.
  5. Verifica se ci sono allegati.
  6. Ottieni i nomi dei file di eventuali allegati e salvali.

Il seguente frammento di codice mostra come analizzare i file di messaggi Microsoft Outlook.

// The path to the File directory and Load Microsoft Outlook email message file
String dataDir = "data/";
MapiMessage msg = MapiMessage.fromFile(dataDir + "message3.msg");

// Obtain subject of the email message, sender, body and Attachment count
System.out.println("Subject:" + msg.getSubject());
System.out.println("From:" + msg.getSenderName());
System.out.println("Body:" + msg.getBody());
System.out.println("Attachment Count:" + msg.getAttachments().size());

// Iterate through the attachments
for (MapiAttachment attachment : msg.getAttachments()) {
    // Access the attachment's file name and Save attachment
    System.out.println("Attachment:" + attachment.getFileName());
    attachment.save(dataDir + attachment.getLongFileName());
}