Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,482 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
Any one can suggest that how to retrieve digitally signed PDF document from email attachment using Graph API in C#.
We have so many such email which needs to read the content from digitally signed PDF document.
When I am trying to retrieve digitally signed pdf from email attachment, I am getting only "smime.p7m"
Here is my Code
OutlookItem outlookItem = null;
var result = (ItemAttachment)_appClient.Users[_appSettings.MailBox].Messages[message.Id].Attachments[attachment.Id]
.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Expand = new string[] { "microsoft.graph.itemattachment/item" };
}).Result;
outlookItem = result.Item;
if (outlookItem != null && outlookItem is Message)
{
Message messageItem = outlookItem as Message;
if (messageItem != null && messageItem.Attachments.Count > 0)
{
foreach (var attachment1 in messageItem.Attachments)
{
if (attachment1 is FileAttachment)
{
var fileAttachment = (FileAttachment)attachment1;
string file_extension = Path.GetExtension(fileAttachment.Name);
if (file_extension == "" || file_extension.ToLower() == ".png" || file_extension.ToLower() == ".jpg" || file_extension.ToLower() == ".jpeg")
{
continue;
}
string fileName = string.Empty;
fileName = GenerateFileName(attachment1.Name);
var filePath = string.Concat(AttachmentPath, fileName);
fileAttachment.Save(filePath); // I am not getting actaul attachement.
}
}
}
}
Thank you in advance