cancel
Showing results for 
Search instead for 
Did you mean: 
WarrenBelz

Email PDF of screen without (and with) a Flow

A short blog from a post I answered that may be helpful. The need to send a screenshot (it could be a form, invoice or anything else) as an email attachment straight from Power Apps is highly useful.
The process actually is very simple using the PDF() function. Firstly, a temporary variable needs to be created with the file content and that used to form the email attachment. This one is to the user, but could be to any address.

With(
   {_PDF: PDF(ScreenName)},
   Office365Outlook.SendEmailV2(
      User().Email,
      "Subject here",
	  "Body here",
      {
         Attachments: 
        {
            Name: "PDFFileName.pdf",
            ContentBytes: _PDF
        }
     }
  )
)

Note also you can send the same content to a Flow, but need to convert it to Base64

With(
   {
      _PDF: PDF(ScreenName),
      _JSON: 
      With(
         {
            _JSONI: 
            JSON(
               _PDF,
               JSONFormat.IncludeBinaryData
            )
         },
         Mid(
            _JSONI,
            Find(
               ",",
               _JSONI
            ) + 1,
            Len(_JSONI) - 
            Find(
               ",",
               _JSONI
            ) - 1
         )
      )
   },
   AttachFileFlow.Run(
      _JSON,
      User().Email,
      "Test Subject",
      "Test Body",
      "TestFile.pdf",
   )
)

then do the normal base64ToBinary in the Flow

 

AttachPDFFlow.png

Comments