How to Create PDF from Email Using Power Automate

How to Create PDF from Email Using Power Automate

Organizations often need to archive important emails for auditing, compliance, legal requirements, and document management. Manually saving emails as PDF files can be time-consuming and prone to errors.

Using Power Automate, you can automatically convert Outlook emails into PDF documents and store them in SharePoint, OneDrive, or other document repositories.

Business Scenario

Suppose your customer support team receives hundreds of emails every day. Instead of manually saving each email, Power Automate can automatically create PDF files and store them in a SharePoint document library for future reference.

Step 1: Create Automated Cloud Flow

  1. Open Power Automate.
  2. Click Create.
  3. Select Automated Cloud Flow.
  4. Choose "When a new email arrives (V3)" trigger.
  5. Configure Outlook settings.

Step 2: Create HTML Content

<html>
<body>

<h2>Email Details</h2>

<b>From:</b>
@{triggerOutputs()?['body/from']}

<br><br>

<b>Subject:</b>
@{triggerOutputs()?['body/subject']}

<br><br>

<b>Received:</b>
@{triggerOutputs()?['body/receivedDateTime']}

<br><br>

@{triggerOutputs()?['body/body']}

</body>
</html>

Step 3: Create HTML File

File Name:

Email_@{formatDateTime(
utcNow(),
'yyyyMMddHHmmss'
)}.html

Store the HTML content temporarily in OneDrive or SharePoint.

Step 4: Convert HTML to PDF

Convert File

Source:
HTML File

Target:
PDF

Use OneDrive for Business Convert File action or third-party PDF connectors.

Step 5: Save PDF File

File Name:

@{replace(
triggerOutputs()?['body/subject'],
'/',
'-'
)}
_@{formatDateTime(
utcNow(),
'yyyyMMddHHmmss'
)}.pdf

Save the generated PDF file into SharePoint, OneDrive, or another storage location.

Flow Design

When New Email Arrives
           ↓
Create HTML Content
           ↓
Create HTML File
           ↓
Convert File to PDF
           ↓
Create PDF File
           ↓
Store in SharePoint

Common Use Cases

Important: Use unique file names with timestamps to prevent PDF files from being overwritten when multiple emails have the same subject.

Benefits

Key Takeaways