Quantcast
Channel: Aspose.Email Product Family
Viewing all articles
Browse latest Browse all 1367

Sending HTML as mail body with embedded fonts etc.

$
0
0
Hi,
I have a PDF document which I have converted to HTML using Aspose.PDF.
I have embedded everything into the html (see code below).

When using the "HtmlLoadOptions" of Aspose.Email and sending the email - the output in Microsoft Outlook (and the web-interface), looks strange. However, if I use the "view in webbrowser" in Outlook, the result is better (see attached pictures)

I have used the following code:

            Dim pdfDoc As New Aspose.Pdf.Document(pdfStream)

            Dim newOptions = New Aspose.Pdf.HtmlSaveOptions()
            newOptions.RasterImagesSavingMode = Aspose.Pdf.HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground
            newOptions.FontSavingMode = Aspose.Pdf.HtmlSaveOptions.FontSavingModes.SaveInAllFormats
            newOptions.PartsEmbeddingMode = Aspose.Pdf.HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml
            newOptions.LettersPositioningMethod = Aspose.Pdf.HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss
            newOptions.SplitIntoPages = False
            newOptions.CustomHtmlSavingStrategy = New Aspose.Pdf.HtmlSaveOptions.HtmlPageMarkupSavingStrategy(AddressOf SavingToStream)
            pdfDoc.Save("C:\Test\DoesNotMatter.html", newOptions)


--

        Private Shared Sub SavingToStream(ByVal htmlSavingInfo As Aspose.Pdf.HtmlSaveOptions.HtmlPageMarkupSavingInfo)
            Dim loadOptions As New Aspose.Email.Mail.HtmlLoadOptions()

            Dim message = Aspose.Email.Mail.MailMessage.Load(htmlSavingInfo.ContentStream, loadOptions)
            message.From = "Something"
            message.To = "Something"
            message.Subject = "Something"

            ' Send the message using Aspose.Email
            Dim client As New Aspose.Email.Mail.SmtpClient()
            client.Host = "Something"
            client.Port = 25
            client.Send(message)
        End Sub

--

Earlier I have used the "Save as MHTML" (in Aspose.Words), but this option is not available in Aspose.PDF

Am i doing something wrong, or how am I able to insert my PDF document as the "mail body"?
Since the "Save as MHTML" is not available, I have tried to save the pdf as HTML, but its not working 100% just yet

Hope you can help :)

Viewing all articles
Browse latest Browse all 1367

Trending Articles