Análisis de Archivos de Mensajes de Microsoft Outlook
Contents
[
Hide
]
Con Aspose.Email, puedes analizar mensajes de Microsoft Outlook en solo unas pocas líneas de código. Este artículo muestra cómo. 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 electrónico.
- Obtener el asunto del correo electrónico.
- Obtener el nombre del remitente.
- Obtener el cuerpo completo del mensaje.
- Averiguar si hay archivos adjuntos.
- Obtener los nombres de archivo de los archivos adjuntos y guardarlos.
El siguiente fragmento de código te muestra cómo analizar archivos de mensajes de Microsoft Outlook.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory and Load Microsoft Outlook email message file | |
string dataDir = RunExamples.GetDataDir_KnowledgeBase(); | |
MapiMessage msg = MapiMessage.FromFile(dataDir + "message3.msg"); | |
// Obtain subject of the email message, sender, body and Attachment count | |
Console.WriteLine("Subject:" + msg.Subject); | |
Console.WriteLine("From:" + msg.SenderName); | |
Console.WriteLine("Body:" + msg.Body); | |
Console.WriteLine("Attachment Count:" + msg.Attachments.Count); | |
// Iterate through the attachments | |
foreach (MapiAttachment attachment in msg.Attachments) | |
{ | |
// Access the attachment's file name and Save attachment | |
Console.WriteLine("Attachment:" + attachment.FileName); | |
attachment.Save(dataDir + attachment.LongFileName); | |
} |