Exchange открыть файл вложение MSG - PullRequest
0 голосов
/ 25 сентября 2019

Привет всем, я пытаюсь получить содержимое почты на outlook, это письмо имеет .msg как attachment, и я пытаюсь открыть его.

                if (message.HasAttachments)
                {
                    try
                    {
                        var sender = message.Sender.Address;
                        var processed = ProcessAttachment(message, tmpStartFolder, tmpExtractFolder, dataCapFolder,sender);
                        emailMessage.Move(processed ? processFolder.Id : attentionFolder.Id);
                    }
                    catch (Exception r)
                    {
                        _logContext.Log(LoggerMessageType.Error, $"Function: ProcessImageList | Message: {r.Message} | Inner Message: {(r.InnerException != null ? r.InnerException.Message : "")}", DateTime.Now, Administrator, Environment.MachineName);
                    }
                }

 private bool ProcessAttachment(Item message, string tmpStartFolder, string tmpExtractFolder, string dataCapFolder, string sender)
{
    foreach (var fileAttachment in message.Attachments.Select(attachment => attachment as FileAttachment))
    {

    }
}

У message есть электронная почта, а my fileAttachment.Name имеет значение null, что означает, что веб-служба Exchange не разрешает .msg?

1 Ответ

0 голосов
/ 25 сентября 2019

jpg

foreach (Attachment att in message.Attachments)
{
            //Load the attachment 
            att.Load();
            //turnt the message.Attachments to a Item(Object)
            ItemAttachment ItemAtt = att as ItemAttachment;
            //Create a ItemSchema of Attachments in itemAtt  
            ItemAtt.Load(new PropertySet(ItemSchema.Attachments));
            foreach (Attachment scannedAttachment in ItemAtt.Item.Attachments)
            {
                scannedAttachment.Load();
                //Loads all Item Attachments as File Attachments
                FileAttachment fileAttachment = scannedAttachment as FileAttachment;
                if (Regex.IsMatch(fileAttachment.Name, ".pdf|.PDF|.Pdf"))
                {

                }
            }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...