Analisando Arquivos de Mensagens do Microsoft Outlook
Contents
[
Hide
]
Com Aspose.Email, você pode analisar mensagens do Microsoft Outlook em apenas algumas linhas de código. Este artigo mostra como. Aspose.Email possui classes para realizar muitas tarefas de programação com mensagens do Outlook. O exemplo de código abaixo mostra como:
- Carregar uma mensagem de email.
- Obter o assunto do email.
- Obter o nome do remetente.
- Obter o corpo completo da mensagem.
- Descobrir se há anexos.
- Obter os nomes dos arquivos de quaisquer anexos e salvá-los.
O seguinte trecho de código mostra como analisar arquivos de mensagens do 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); | |
} |