It seems you’re trying to send an email with a PDF attachment using the Microsoft Graph API. From your code, it looks like you’re setting the ContentType to "application/pdf", which is correct for a PDF file.
However, based on the information you provided, it appears that the issue might be with the Name property of the FileAttachment. The Name property should include the file extension. So instead of "Hopefully this is a PDF", it should be "Hopefully this is a PDF.pdf".
Here’s the corrected part of your code:
Attachments = new List<Attachment>
{
new FileAttachment
{
OdataType = "#microsoft.graph.fileAttachment",
Name = "Hopefully this is a PDF.pdf",
ContentBytes = File.ReadAllBytes("C:\\genericpdf.pdf"),
ContentType = "application/pdf",
},
},
This should ensure that the attached file is recognized as a PDF in the email. Please give this a try and see if it resolves your issue.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".