Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,645 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I am using below code to access mail file attachments. I have two questions;
Thanks
Regards
var inboxMessages = await graphClient
.Users[user.Id]
.MailFolders.Inbox
.Messages
.Request()
.GetAsync();
foreach(Microsoft.Graph.Message message in inboxMessages) {
if (message.HasAttachments == true) {
var attachments = await graphClient
.Users[user.Id]
.Messages[$ "{message.Id}"]
.Attachments
.Request()
.GetAsync();
foreach(var attachment in attachments) {
if (attachment is FileAttachment) {
FileAttachment fileAttachment = attachment as FileAttachment;
//Save fileAttachment content to file here
}
}
}
}