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 Platform Community / Forums / Power Automate / Transfer mail attachme...
Power Automate
Suggested Answer

Transfer mail attachment to SQL database table

(0) ShareShare
ReportReport
Posted on by 2
Hi Techiez,
 
 

I need help creating a flow that transfers CSV data from email attachments to a SQL database whenever an email is received on a weekly basis.

 

thanks-Deepan.


 
Categories:
I have the same question (0)
  • Suggested answer
    Riyaz_riz11 Profile Picture
    3,874 Super User 2025 Season 2 on at
    Hi,
    1. Trigger: When a new email with attachments arrives in Outlook.
    2. Get Attachments: Use the "Get attachments" action to retrieve all attachments from the email.
    3. Loop through attachments: Use a "Apply to each" action to iterate through each attachment.
    4. Get attachment content: Use the "Get attachment content" action to get the content of the current attachment.
    5. Convert to Base64 (if needed): Use the "Convert to Base64" action to encode the binary content of the attachment.
    6. Connect to SQL: Use the "Open SQL connection" action to connect to your SQL Server database.
    7. Construct SQL query: Create an INSERT statement to add the attachment data to your SQL table: 
       
    Code
        INSERT INTO YourTableName (AttachmentName, AttachmentData) VALUES ('[AttachmentName]', '[AttachmentData]');
    1. 1. Execute SQL statement:
      Use the "Execute SQL statement" action to run the INSERT statement. Replace [AttachmentName] with the name of the attachment and [AttachmentData] with the base64 encoded data.
    2. 2. Close SQL connection:
      Use the "Close SQL connection" action to close the connection to your database. 
       
     
    • Data Types:
      Ensure that the data types in your SQL table are compatible with the attachment data you are inserting (e.g., VARBINARY for binary data, NVARCHAR for text-based data, etc.).

      If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.
      Regards,
      Riyaz

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard