cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
altricay
Frequent Visitor

Send Email with Collection

Hi All,

 

I was trying to:
1. There are 3 record items on gallery i.e. GalleryOTApprove and only retrieve those if Backchargeable="Yes".

2. Retrieve and pass the email address from another SP list i.e. SubconList then store it to a collection called colWInfo.

3. Send email to the recipient email addresses (from colWInfo) with the records from GalleryOTApprove e.g. WorkerName.

Send email button
OnSelect:
Clear(colWInfo);
ForAll(
GalleryOTApprove.AllItems,
If(Backchargeable="Yes", Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail});
SEOffice365Outlook.SendEmailV2(colWInfo.vmail,"test",WorkerName))

);

With the coding above, I've got an error i.e. "Invalid argument type (Table). Expecting a text value instead . The function SendEmailV2 has some invalid arguments".

I did test by putting a fixed email address i.e. abc@company.com and powerapps managed to send 3 emails with different worker name in email body.  The subcon's email addresses are successfully stored in colWInfo as images below:

altricay_0-1631976688579.png

altricay_1-1631976786562.png

 

 



May I know is there a way to fix the above issue?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Community Champion
Community Champion

HI @altricay 

Getting email using Filter is a table. So we have to use First(vSEmail).SEmail

 

Please update the command

Clear(colWInfo);
ForAll(
GalleryOTApprove.AllItems,
If(Backchargeable="Yes", Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail});
));

ForAll(
    colWInfo,
    Office365Outlook.SendEmailV2(
        First(vSEmail).SEmail,
        "Subject",
        "Body",
        {Importance: "High"}
    )
);

 

View solution in original post

8 REPLIES 8
Jeff_Thorpe
Super User
Super User

I think you need to convert the table into a string separating the values with a semi colon. In the email function try replacing the colWInfo.vSEmail with the formula below.

 

Concat( colWInfo, vSEmail, ";")

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Hi Jeff,

 

Thanks for prompt reply. But each of records in Gallery carries different recipient email addresses.  If I concatenate them with ";", wouldn't powerapp send all three records to all three different recipients? Actually my objective is to send each record to different recipients. 

altricay_0-1631978079265.png

Please advise. 

Thanks.

StalinPonnusamy
Community Champion
Community Champion

Hi @altricay 

 

If gallery has email id then we can loop through Gallery items to send email

 

ForAll(
    BrowseGallery1.AllItems,
    Office365Outlook.SendEmailV2(
        ThisRecord.EmailId, //To Email
        Subject.Text,
        "Body",
        {Importance: "High"}
    )
);

 

 

 

If the gallery does not have email then you need to collect the information first and loop it through Collection

Clear(colWInfo);
ForAll(
GalleryOTApprove.AllItems,
If(Backchargeable="Yes", Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail});
));

ForAll(
    colWInfo,
    Office365Outlook.SendEmailV2(
        vSEmail,
        "Subject",
        "Body",
        {Importance: "High"}
    )
);

 

 

Hi Stalin,

 

Unfortunately my Gallery's source, i.e., OTLineItemList, doesn't carry email address of the subcon.  That's why I grab it from another list called SubconList with the code below:
Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail})

 

I managed to grab their email addresses but the problem is SendEmailV2 doesn't recognize table value in colWInfo.

 

Any idea to convert the value of colWInfo to text?

 

Thank you.

StalinPonnusamy
Community Champion
Community Champion

Hi @altricay 

 

I sent an updated one while you are replying. Please take a look this

Clear(colWInfo);
ForAll(
GalleryOTApprove.AllItems,
If(Backchargeable="Yes", Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail});
));

ForAll(
    colWInfo,
    Office365Outlook.SendEmailV2(
        vSEmail,
        "Subject",
        "Body",
        {Importance: "High"}
    )
);

It doesn't work as shown on below:

 

altricay_0-1632036971626.png

 

StalinPonnusamy
Community Champion
Community Champion

HI @altricay 

Getting email using Filter is a table. So we have to use First(vSEmail).SEmail

 

Please update the command

Clear(colWInfo);
ForAll(
GalleryOTApprove.AllItems,
If(Backchargeable="Yes", Collect(colWInfo, {vSEmail: Filter(SubconList,ID = SIDNo).SEmail});
));

ForAll(
    colWInfo,
    Office365Outlook.SendEmailV2(
        First(vSEmail).SEmail,
        "Subject",
        "Body",
        {Importance: "High"}
    )
);

 

View solution in original post

altricay
Frequent Visitor

It works well.  Thank you so much Stalin.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,239)