cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SimeonWilliams
Level: Powered On

Send attachment in Emails using SMTP Connection

Hello, I am trying to send an email with attachments using the 'OnSelect' from a button using the code below using the SMTP connection ...

 

SMTP.SendEmailV2({
From:User().Email,
To:SLoc_Email.Selected.Value,
CC:User().Email,
Subject:"Power Apps 2 - Sloc - " & DropDown_Sloc.Selected.Value,
Body:"<Bold>PowerApps Testing.</Bol> <br><br><br>
This is from " & User().FullName & "<br>
SAP Mvt Type - " & DataCardValue_SAPMvtType.Selected.Value,
IsHtml:true,
Attachments:Table({ FileName: "TheImage.jpg" }, { ContentId: "1" }, { ContentData: Image2.Image }, { ContentType: ""})
});

 

.... Now the code sends the email, that is not a problem but the attachment does not send properly. I get an attached file called 'noname' that does not even have an extension added to the file. If I download the file and add the extension '.png'  to it, it loads and shows me the image.

 

What am I doing wrong?

1 REPLY 1
Community Support Team
Community Support Team

Re: Send attachment in Emails using SMTP Connection

Hi @SimeonWilliams,

 

Properties for attachment are as below according to https://www.carlosag.net/PowerApps/Connectors/SMTP#_Toc69EE4BCA_AttachmentV2:

Name

Type

Summary

ContentData

string(byte)

Content data

Content data

ContentType

string

Content type

Content type

FileName

string

File name

File name

ContentId

string

Content id

Content id

 

It seems that your formula has put the ContentType part to the FileName part. Try:
Attachments:Table({ FileName: "TheImage" }, { ContentId: "1" }, { ContentData: Image2.Image }, { ContentType: ".jpg"})

Regards,

Mona

 

 

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 314 members 5,789 guests
Please welcome our newest community members: