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)