Analizar archivos de mensajes de Microsoft Outlook
Contents
[
Hide
]
Con Aspose.Email, puede analizar mensajes de Microsoft Outlook en solo unas pocas líneas de código. Este artículo muestra cómo hacerlo. Aspose.Email tiene clases para realizar muchas tareas de programación con mensajes de Outlook. El ejemplo de código a continuación muestra cómo:
- Cargar un mensaje de correo.
- Obtener el asunto del correo.
- Obtener el nombre del remitente.
- Obtener el cuerpo completo del mensaje.
- Descubrir si hay adjuntos.
- Obtener los nombres de archivo de los adjuntos y guardarlos.
El siguiente fragmento de código le muestra cómo analizar archivos de mensajes de 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());
}