Email to Image Conversion

Technical support for Spire.Email

Moderator: iceblue support

Email to Image Conversion

Postby vernon1111 » Fri Oct 19, 2018 9:54 am

I would like to know if there is anyway we can convert an email to an image.

I understand that you can convert the email to a MHTML file.

I am aware that is it not possible to do so directly as there is no such function for spire email, perhaps we can do it something like email => MHTML = >image or email > html => image.

Please advise or suggestion alternative.
thanks
vernon1111
 
Posts: 7
Joined: Fri Mar 02, 2018 4:34 am

Re: Email to Image Conversion

Postby Nina.Tang » Fri Oct 19, 2018 10:44 am

Dear Vernon,

Thanks for your inquiry.
Yes, there is no directly method to do the conversion from email to image. You could extract the text from email first.
Extract message contents

Then convert the text to image, both Spire.Doc and Spire.PDF support the function.
Spire.Doc:
Code: Select all
Document doc = new Document();
doc.LoadText("ExtractMessageContents.txt");
Image image = doc.SaveToImages(0, ImageType.Bitmap);
image.Save("result.png", ImageFormat.Png);

Spire.PDF:
Code: Select all
string text = File.ReadAllText("ExtractMessageContents.txt");
PdfDocument doc = new PdfDocument();
PdfSection section = doc.Sections.Add();
PdfPageBase page = section.Pages.Add();
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11);
PdfStringFormat format = new PdfStringFormat();
format.LineSpacing = 20f;
PdfBrush brush = PdfBrushes.Black;
PdfTextWidget textWidget = new PdfTextWidget(text, font, brush);
float y = 0;
PdfTextLayout textLayout = new PdfTextLayout();
textLayout.Break = PdfLayoutBreakType.FitPage;
textLayout.Layout = PdfLayoutType.Paginate;
RectangleF bounds = new RectangleF(new PointF(0, y), page.Canvas.ClientSize);
textWidget.StringFormat = format;
textWidget.Draw(page, bounds, textLayout);
doc.SaveAsImage(0).Save("result2.png");

Please download our Spire.Office Platinum (DLL Only) Version:3.10.2 and have a try.

Sincerely,
Nina
E-iceblue support team
User avatar
Nina.Tang
 
Posts: 602
Joined: Tue Sep 27, 2016 1:06 am

Re: Email to Image Conversion

Postby vernon1111 » Sat Oct 20, 2018 3:15 am

Hi Nina,

Thanks for the suggestion.

Is there anyway we can generate the image with the original styling from the mailbody and inline images?
vernon1111
 
Posts: 7
Joined: Fri Mar 02, 2018 4:34 am

Re: Email to Image Conversion

Postby Nina.Tang » Mon Oct 22, 2018 2:26 am

Hi,

Thanks for your feedback.
Sorry there is no suitable method to achieve your demand at present. We will consider adding a new feature to make it available. If it is achievable in the future, we will inform you.

Sincerely,
Nina
E-iceblue support team
User avatar
Nina.Tang
 
Posts: 602
Joined: Tue Sep 27, 2016 1:06 am


Return to Spire.Email

Who is online

Users browsing this forum: No registered users and 0 guests