web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Convert email to pdf

(0) ShareShare
ReportReport
Posted on by

Basically I have a very simple workflow that is supposed to be triggered by when I receiver a certain e-mail in my outlook, that then converts the e-mail to a PDF and updates it to a sharepoint file library.

 

I have done this workflow before with other e-mails and it has worked fine. Attached are screen shots. I have tried two things one where I specify the file’s extension as .html and another one as a .eml. Both yield errors.

 

When I specify HTML the workflow runs for a while. And then gives me this error:  Error 502 Gateway:

 

{

  "error": {

    "code": 502,

    "source": "flow-apim-msmanaged-na-northcentralus-01.azure-apim.net",

    "clientRequestId": "722875f0-b6ea-4d77-b3df-d2695ab6b2bd",

    "message": "BadGateway",

    "innerError": {

      "status": 502,

      "message": "IndexOutOfRangeException: Index was outside the bounds of the array.\nInnerExceptionMessage: \nStackTrace:    at System.String.get_Chars(Int32 index)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.CssParser.ParseFontFamilyProperty(String propValue)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.CssParser.ParseFontFamily(String value)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.TranslateAttributes(HtmlTag tag, CssBox box)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.CascadeApplyStyles(CssBox box, CssData cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.Parse.DomParser.GenerateCssTree(String html, HtmlContainerInt htmlContainer, CssData& cssData)\r\n   at TheArtOfDev.HtmlRenderer.Core.HtmlContainerInt.SetHtml(String htmlSource, CssData baseCssData)\r\n   at TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.AddPdfPages(PdfDocument document, String html, PdfGenerateConfig config, CssData cssData, EventHandler`1 stylesheetLoad, EventHandler`1 imageLoad)\r\n   at TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(String html, PageSize pageSize, Int32 margin, CssData cssData, EventHandler`1 stylesheetLoad, EventHandler`1 imageLoad)\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<>c__DisplayClass12_1.<GenerateStream>b__1() in C:\\source\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 83\r\n   at OneDrive.Media.Utilities.MemoryStreamHelper.ExecuteAndDisposeStreamIfErrorOccurs(Stream outputStream, Action method) in C:\\source\\Utilities\\MemoryStreamHelper.cs:line 62\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<>c__DisplayClass12_0.<GenerateStream>b__0() in C:\\source\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 101\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlRasterizer.ExecuteMethod(Func`1 method) in C:\\source\\Transforms\\Rasterizers\\HtmlRasterizer.cs:line 110\r\n   at OneDrive.Media.Transforms.Rasterizers.HtmlToPdfConverter.<GeneratePdfAsync>d__11.MoveNext() in C:\\source\\Transforms\\PdfConverters\\HtmlToPdfConverter.cs:line 58\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at OneDrive.Media.Utilities.Sandbox.SandboxService.<RunRequestAsync>d__1.MoveNext() in C:\\source\\Sandbox\\SandboxService.cs:line 85\n ThrowSite: ",

      "source": "api.connectorp.svc.ms"

    }

  }

}

 

 

When I specify it as a .eml it errors at the same step with a different error:  Conversion of this file to PDF is not supported. (Sandbox_BadArgument_Argument / Invalid destination page in call to CreateDocumentLink: page number is one-based and must be 1 or higher.)

 

Screenshots of flow

 

112233

 

Categories:
I have the same question (0)
  • MF-12051538-0 Profile Picture
    402 on at

    Hi @SharePointNinja ,

     

    You shouldn't need the compose step above, and you can use .msg as the file extension. This test flow seemed to do the trick for me:

    NuttyPistons_0-1640021056972.png


    If this solved your problem, please Accept this post as the solution.



  • Verified answer
    v-jefferni Profile Picture
    on at

    Hi @SharePointNinja ,

     

    Please refer to below thread:

    https://powerusers.microsoft.com/t5/Building-Flows/save-email-as-pdf/td-p/109005

     

    In addition, the compose action is not necessary in your case, you may try change the file name from the output of compose to a fixed value such as the Email subject, and check if it is the output of compose caused the problems.

     

    Hope this helps.

     

    Best regards,

    Community Support Team _ Jeffer Ni
    If this post helps, then please consider Accept it as the solution to help the other members find it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard