-
Notifications
You must be signed in to change notification settings - Fork 435
Description
I am trying to convert email message with pdf attachment to pdf with attachment as hyperlink.
foreach (var attachment in message.Attachments)
{
if (attachment is MimePart mimePart)
{
if (attachment.ContentType.MediaType.Equals("application", StringComparison.OrdinalIgnoreCase) &&
attachment.ContentType.MediaSubtype.Equals("pdf", StringComparison.OrdinalIgnoreCase))
{
byte[] contentArray = null;
using (var memoryStream = new MemoryStream())
{
mimePart.Content.DecodeTo(memoryStream);
contentArray = memoryStream.ToArray();
}
var base64Data = Convert.ToBase64String(contentArray);
var fileURL = $"data:application/pdf;base64,{base64Data}";
var hyperlink= $"
PDF Attachment:{mimePart.FileName}
";//var hyperlink= $"
PDF Attachment:<a href='https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
// download='{mimePart.FileName}' target='_blank'>{mimePart.FileName}
first link which is created from base 64 is not working while second one is working. If i paste the same content in html it's opening from that html page.