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,
ToSmiley FrustratedLoc_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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 64 members 3,515 guests
Recent signins:
Please welcome our newest community members: