Analisi dei file di messaggi Microsoft Outlook
Contents
[
Hide
]
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:
- Carica un messaggio email.
- Ottieni l’oggetto dell’email.
- Ottieni il nome del mittente.
- Ottieni il corpo completo del messaggio.
- Verifica se ci sono allegati.
- 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());
}