cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kollenel26
Frequent Visitor

Powerapps mail attachment from SQL/Blob Storage

Hi guys, I've been having some trouble with the following scenario, I recently moved my pdfs from a SharePoint list to a SQL database and have been storing pdfs in a varchar(max) column, this works fine for viewing and saving. However, I now need to send those documents as an email attachment. Using the Outlook365 attachment gives me an error that it is not in blob format. I then created an Azure blob storage container and save the pdfs there, but I do not know how to get the documents from the blob storage into a mail attachment in powerapps, any help would be greatly appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Kollenel26 ,

Could you please share a bit more about the PDF file data stored in your SQL Table? Is it stored as Blob data?

Do you want to retrieve all blobs (PDF files) from a specific folder in your Azure Blob Storage, and then attach them as attachments of the email?

 

Based on the needs that you mentioned, I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Send Email" button to following:

Office365Outlook.SendEmailV2(
                            "User1@email.com", 
                            "Subject Text Here", 
                            "Email Body Message Here", 
                            {
                               Attachments: ForAll(
                                                   AzureBlobStorage.ListFolderV2("Type your Specific Folder Id here").value,
                                                  {
                                                    Name: DisplayName,
                                                    ContentBytes: AzureBlobStorage.GetFileContent(Id),
                                                    '@odata.type': ""
                                                  }
                                            )
                            }
);

Note: You need to add Office 365 Outlook connection and AzureBlobStorage connection within your app firstly.

 

More details about sending an email with attachments in canvas app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-outloo...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xida-msft
Community Support
Community Support

Hi @Kollenel26 ,

Could you please share a bit more about the PDF file data stored in your SQL Table? Is it stored as Blob data?

Do you want to retrieve all blobs (PDF files) from a specific folder in your Azure Blob Storage, and then attach them as attachments of the email?

 

Based on the needs that you mentioned, I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Send Email" button to following:

Office365Outlook.SendEmailV2(
                            "User1@email.com", 
                            "Subject Text Here", 
                            "Email Body Message Here", 
                            {
                               Attachments: ForAll(
                                                   AzureBlobStorage.ListFolderV2("Type your Specific Folder Id here").value,
                                                  {
                                                    Name: DisplayName,
                                                    ContentBytes: AzureBlobStorage.GetFileContent(Id),
                                                    '@odata.type': ""
                                                  }
                                            )
                            }
);

Note: You need to add Office 365 Outlook connection and AzureBlobStorage connection within your app firstly.

 

More details about sending an email with attachments in canvas app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/connections/connection-office365-outloo...

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Thanks a million, that works, apologies, I am quite new to all this, so I followed one tutorial where I used the add picture control to upload a pdf and then create a file in my azure blob storage, your method works to send the mail but ideally I would like to select one or more out of a folder. for one component of the app.

For the next component: I am creating certificates per candidate using a flow, this updates a varchar(max) column in a SQL database with the Muhimbi converted pdf per learner, now I could create a blob for each of them simultaneously and retrieve them using your code, I would just need to figure out how to filter my blob container. Or if I could somehow upload the SQL column data to the blob storage that would be ideal seeing as I could then create and delete once the mail is sent and keep my blob container empty for neatness sake, I am just not so clued up with the data types, the converted pdf is in the form of "JVBERI0XlJ..." which is a massive text file, I am not sure how to upload that as a blob and then get selected ones back again?

P.S I am using varchar(max) in the SQL table because that is the only way I could get pdfs to display in the pdfviewer in the app, the image type gave all sorts of errors

 

Hi @Kollenel26 ,

Is the solution I provided above helpful in your scenario?

 

If you have solved your current problem, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

If you have another needs within your scenario, please consider open another thread in our forum.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the help on this.  This has help me down the right road.

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (65,050)