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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Attachments don't work...
Power Apps
Answered

Attachments don't work with docs or PDFs

(0) ShareShare
ReportReport
Posted on by 27

I'm trying to send attachments in my email. JPGs and PNGs are sent fine but docs and pdfs won't go through. Any ideas?

 

Office365Outlook.SendEmailV2(
myemail@example.com,
"Header",
"Body",
{
Attachments: RenameColumns(
AttachmentsValue.Attachments,
"Value",
"ContentBytes"
)
}
);

Categories:
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @altyrocks ,

     

    Have a good day. What's AttachmentsValue.Attachments ?

    Could you share its columns name and its structure?

     

    I used sharepoint list atthacment and it worked. Please see the screenshots.

    vxiaochenmsft_0-1664161844505.png

    vxiaochenmsft_1-1664161908296.png

    vxiaochenmsft_2-1664161953291.png

    vxiaochenmsft_3-1664161965617.png

     

    Best Regards,

    Wearsky

  • altyrocks Profile Picture
    27 on at

    Hello! 

    Thank you so much for your reply. This is how it's listed in the SharePoint list. I'm not sure how it's defined or what the datatype is as this was an existing list that I need to add a UI to. 

     

    altyrocks_0-1664213468859.png

     

    AttachmentsValue is defined as type Attachments.

     

    altyrocks_1-1664213686665.png

     

    I tried your syntax and it didn't like it so I must not have something defined right. 

     

  • altyrocks Profile Picture
    27 on at

    It looks like AttachmentsValue.Attachments is defined as a table...

     

    altyrocks_0-1664214086504.png

     

  • altyrocks Profile Picture
    27 on at

    Also, I don't appear to have an ID or Name property either. 

     

    altyrocks_0-1664230187990.png

     

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @altyrocks ,

     

    Don't worry about the column name because the attachment control does not have these column names.

    I did a test again with the attachment control as you created in your app.

    Unfortunately, I can't reproduce the problem. Please see the screenshots below.

    vxiaochenmsft_0-1664244039575.png

    You can see that I have 3 files in the attachment control and 2 of them are unsaved and the other one is saved in sharepoint list attachment column.

    vxiaochenmsft_1-1664244146910.png

    vxiaochenmsft_2-1664244164174.png

     

    I copied your formula and test it . It sended the correct email.

    vxiaochenmsft_3-1664244217382.png

     

    What did I miss?

     

    Best Regards,

    Wearsky

  • altyrocks Profile Picture
    27 on at

    Hi Wearsky,

     

    So I noticed you were executing the code from a button. When I mimiced this, it worked great and the email sent successfully with a word document. However, I only submit an email on a successful submission of a form after it passes all validations so I put the code in the OnSuccess method of the EditForm1. When I did this, the email was sent successfully but failed to include the word document.

     

    To give you some background, I am trying to make this PowerApp behave like a standard survey form (fill in the blanks and hit submit). On a successful submission, it sends an email. To accomplish this, I use the EditForm1 and set the DefaultMode to FormMode.New. Then I use the Self.LastSubmit function to grab the data from the screen instead of the default behavior which is to grab data from the last saved record. 

     

    To be totally transparent, I have included the entire code snippet for the OnSuccess method. When I tried to paste this code into the OnSelect function of the Submit button, it did not like the Self.LastSubmit function and gave me errors. 

     

    Do I need to incorporate the Self.LastSaved into the Attachments call on the OnSuccess funtion? 

     

    So if I understand this correctly, I need to be able to either:

    a.) Get word docs and pdfs included in an email in the OnSuccess method of the EditForm1

    or

    b.) Pull screen data and only submit emails on successful submissions of the OnSelect method of a button. 

     

    Office365Outlook.SendEmailV2(
    SubmitButtonKey,
    "Dining Vendor Incident",
    "<table><tr><td><strong>" & IDKey.Text & "</strong></td><td>" & Self.LastSubmit.'ID (Title)' & "</td></tr><tr><td><strong>" & DateOfIncidentKey.Text & "</strong></td><td>" & Self.LastSubmit.'Date of Incident' & "</td></tr><tr><td><strong>" & LocationKey.Text & "</strong></td><td>" & Self.LastSubmit.Location.Value & "</td></tr><tr><td><strong>" & NameKey.Text & "</strong></td><td>" & Self.LastSubmit.Name & "</td></tr><tr><td><strong>" & EmailKey.Text & "</strong></td><td>" & Self.LastSubmit.Email & "</td></tr><tr><td><strong>" & TypeOfIssueKey.Text & "</strong></td><td>" & Self.LastSubmit.'Type of Issue'.Value & "</td></tr><tr><td><strong>" & DescriptionOfIncidentKey.Text & "</strong></td><td>" & Self.LastSubmit.'Description of Incident' & "</td></tr><tr><td><strong>" & VendorKey.Text & "</strong></td><td>" & Self.LastSubmit.Vendor.Value & "</td></tr><tr><td><strong>" & ReoccurringKey.Text & "</strong></td><td>" & Self.LastSubmit.Reoccurring & "</td></tr><tr><td><strong>" & InvoiceNumberKey.Text & "</strong></td><td>" & Self.LastSubmit.'Invoice Number' & "</td></tr><tr><td><strong>" & AttachmentsKey.Text & "</strong></td><td>" & Self.LastSubmit.'Has attachments' & "</td></tr></table>",
    {Attachments:RenameColumns(AttachmentsValue.Attachments,"Value","ContentBytes")});
    Navigate(Screen1)

  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @altyrocks ,

     

    Please try this:

    Office365Outlook.SendEmailV2(
    SubmitButtonKey,
    "Dining Vendor Incident",
    "<table><tr><td><strong>" & IDKey.Text & "</strong></td><td>" & Self.LastSubmit.'ID (Title)' & "</td></tr><tr><td><strong>" & DateOfIncidentKey.Text & "</strong></td><td>" & Self.LastSubmit.'Date of Incident' & "</td></tr><tr><td><strong>" & LocationKey.Text & "</strong></td><td>" & Self.LastSubmit.Location.Value & "</td></tr><tr><td><strong>" & NameKey.Text & "</strong></td><td>" & Self.LastSubmit.Name & "</td></tr><tr><td><strong>" & EmailKey.Text & "</strong></td><td>" & Self.LastSubmit.Email & "</td></tr><tr><td><strong>" & TypeOfIssueKey.Text & "</strong></td><td>" & Self.LastSubmit.'Type of Issue'.Value & "</td></tr><tr><td><strong>" & DescriptionOfIncidentKey.Text & "</strong></td><td>" & Self.LastSubmit.'Description of Incident' & "</td></tr><tr><td><strong>" & VendorKey.Text & "</strong></td><td>" & Self.LastSubmit.Vendor.Value & "</td></tr><tr><td><strong>" & ReoccurringKey.Text & "</strong></td><td>" & Self.LastSubmit.Reoccurring & "</td></tr><tr><td><strong>" & InvoiceNumberKey.Text & "</strong></td><td>" & Self.LastSubmit.'Invoice Number' & "</td></tr><tr><td><strong>" & AttachmentsKey.Text & "</strong></td><td>" & Self.LastSubmit.'Has attachments' & "</td></tr></table>",
    {Attachments:RenameColumns( RenameColumns(
    Self.LastSubmit.Attachments ,
    "Value",
    "ContentBytes"
    ),"DisplayName","Name")});
    Navigate(Screen1)

     

    Best Regards,

    Wearsky

  • altyrocks Profile Picture
    27 on at

    Wearsky!!! You rock!! That fixed it, thanks so much!!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 204 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard