Skip to content

pdf hyperlinks created from base 64 are not working #197

@prasanthi-prasu

Description

@prasanthi-prasu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions