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 Apps / Power Apps Send email ...
Power Apps
Answered

Power Apps Send email with attachments being optional

(0) ShareShare
ReportReport
Posted on by 65

Hi all,

 

I've developed a Power App for logging issues in a Data Centre, users can submit a picture utilising the Add Picture control.

 

The issue I'm facing is that if the user does not attach a picture, the email does not trigger.

 

I've tried to use a condition but I'm still fairly new to Power Apps and cannot figure out how to get it to work without the attachment.

 

Here is the current formula:

 

If(
 IsBlank(imgAttachEmail.Image),
 Office365Outlook.SendEmailV2(
 "Test@TestDomain.Com",
 "New Issue logged via app - With Image",
 "<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText,
{
 Attachments: {
 Name: ambFileAttach.FileName,
 ContentBytes: imgAttachEmail.Image,
 '@odata.type': ""
 }
 }
),
Office365Outlook.SendEmailV2(
 "Test@TestDomain.com",
 "New Issue logged via app",
"<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText
);


The issue I get with it set up like this is that it will send the email with no attachment, whether I attach an image or not.

 

If I switch the attachment part of the formula to the "else" value, it won't work unless there is an attachment.

 

Any help is greatly appreciated!

Categories:
I have the same question (0)
  • rpersad Profile Picture
    776 on at

    No problem. Weird that you have to add the '.Media' while I got it to work without it. But glad it works.

  • MHSPDev Profile Picture
    65 on at

    You are a genius, thank you so much!

     

    I spent hours googling and testing things out before coming here and you've managed to solve it for me.

     

    Updated formula is here:

     

    If(
     IsBlank(ambFileAttach.Media),
     Office365Outlook.SendEmailV2(
     "Test@TestDomain.com",
     "New Issue logged via app",
     "<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText & Navigate(Screen_Confirmation)
     ),
     Office365Outlook.SendEmailV2(
     "Test@TestDomain.com",
     "New Issue logged via app",
     "<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText,
     {
     Attachments: {
     Name: ambFileAttach.FileName,
     ContentBytes: imgAttachEmail.Image,
     '@odata.type': ""
     }
     }
     );
  • MHSPDev Profile Picture
    65 on at

    You are a genius, I've got it working now.

     

    Formula looks like this now:

     

    If(
     IsBlank(ambFileAttach.Media),
     Office365Outlook.SendEmailV2(
     "Test@TestDomain.com",
     "New Issue logged via app",
     "<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText & Navigate(Screen_Confirmation)
     ),
     Office365Outlook.SendEmailV2(
     "Test@TestDomain.com",
     "New Issue logged via app - With Image",
     "<b>Name of Reporter:</b>" & " " & TextInput_Name.Text & "<br>" & "<b>Reporter Email:</b>" & " " & TextInput_Email.Text & "<br>" & "<br>" & "<b>Location of issue:</b>" & " " & TextInput_Location.Text & "<br>" & "<b>Subject of issue:</b>" & " " & TextInput_Subject.Text & "<br>" & "<br>" & "<b><u>Description of issue</u></b>" & " " & RichTextInput_Description.HtmlText,
     {
     Attachments: {
     Name: ambFileAttach.FileName,
     ContentBytes: imgAttachEmail.Image,
     '@odata.type': ""
     }
     }
     );

     

    Thank you so much, spent a few hours trying to get this working and googling all sorts with no luck!

  • Verified answer
    rpersad Profile Picture
    776 on at

    Use !IsBlank(ambFileAttach) which would return true if there is an image selected and false if no image selected.

  • MHSPDev Profile Picture
    65 on at

    I believe it's the Image Control that stores the image.

     

    In the image below I am using the imgAttachEmail (Image Control) to store the image and the ambFileAttach (Add Picture control) for the file name.

    MHSPDev_0-1692362507185.png

     

  • rpersad Profile Picture
    776 on at

    Just for confirmation what control are you using to store the image?

  • MHSPDev Profile Picture
    65 on at

    I get "Invalid argument type (Image). Expecting a Table value instead.

  • rpersad Profile Picture
    776 on at

    Try isEmpty instead of isBlank

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 Apps

#1
Kalathiya Profile Picture

Kalathiya 422

#2
WarrenBelz Profile Picture

WarrenBelz 380 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 325 Super User 2025 Season 2

Last 30 days Overall leaderboard