Solved

Retrieve email from SharePoint list and send one email of all items belongs to the same person


Userlevel 1
Badge +7

Hi - i have a question re SharePoint integration and wonder if it is possible? I have a list of tasks in SP and want to send a weekly update email with all items belongs to each individual. Is it possible via Cloud? Thank you vm.

icon

Best answer by Garrett 20 May 2023, 07:36

View original

17 replies

Userlevel 6
Badge +16

Hi @mjliu 

What did you meant by “I have a list of tasks in SP”?
Is your workflow platform NAC/NWC or O365 or SharePoint 16/19?

 

If you are using NAC/NWC platform - does it mean that you save the Task Details to a SP List?

If you are using Nintex O365 platform - does it mean the Workflow Task List? 

Userlevel 1
Badge +7

Hi @Garrett 

i am using NWC. I meant a list of items in SP and for each item, i have a column called email (one email is corresponding to multiple items). I want to send an email for all the items belongs to the same address on a weekly basis. Can I use the integration between SP and Nintex to achieve it? Thanks!

Userlevel 6
Badge +16

Hi @mjliu 

I thought you wanted to get a list of pending Tasks from NAC/NWC and send reminder emails.
 

There is only a single list, right?
This can be accomplish using nested SPO Query List action

Level 1- Query List. Sorted by Email. Output obj_SortedByEmail
Level 2 - ForEach Loop. Using obj_SortedByEmail → Items

You need to add a checking mechanism. Whether the Email is the same as previous.
If encounter the same email, you append to the email body string
if encounter a different email, send out the email and start building a new body string

Userlevel 6
Badge +16

Lets say that this is our original List

 

Level 1- Query List. Sorted by Email. Output obj_SortedByEmail.
This returns

which we pass into the ForEach Loop

Level 2 - ForEach Loop. Using obj_SortedByEmail → Items

For the first time, var txt_PreviousEmail is not set yet. We save “chen@email.com” into txt_PreviousEmail. We built the email body text

In the second time, compare current item email to var txt_PreviousEmail which return True. We append/built the email body text

In the third time, compare current item email to var txt_PreviousEmail which return True. We append/built the email body text

In the forth time, compare current item email to var txt_PreviousEmail which return FALSE. We send out email to “chen@email.com”. We save “john@email.com” into txt_PreviousEmail. We built a new email body text

Userlevel 1
Badge +7

hi @Garrett 

Thanks vm! it is a single list. So i want to sort the list by a priority column first and then send one single email to the people telling them the request is at priority ** out of number of all requests.

I think i am almost there, but do not know how to add a checking mechanism. Do you have any idea? thanks vm!

Userlevel 6
Badge +16

The Original List

 

Level 1- Query List. Sorted by Email. Output obj_SortedByEmail

 

Level 2 - ForEach Loop. Using obj_SortedByEmail → Items

For first time run, set var txt_PreviousEmail = “chen@email.com”

First run, compare current email to txt_PreviousEmail. result is TRUE
If TRUE, built email body string

Second run and third run, compare urrent email to txt_PreviousEmail.  result is TRUE
If TRUE, append / built email body string

Forth run, compare current email to txt_PreviousEmail. result is FALSE
If FALSE,
1) send email to “chen@email.com”
2) set var txt_PreviousEmail = “john@email.com”
3) built NEW email body string

 

Userlevel 6
Badge +16

Hi @mjliu 

No sure why my post needs to be review by moderators

 

Userlevel 6
Badge +16

Original List

 

Level 1- Query List. Sorted by Email. Output obj_SortedByEmail

 

Checking mechanism - compare the email

Userlevel 6
Badge +16

Checking mechanism - compare the email

IF the emails are the same (current same user vs txt_email)
then append / build the email body string

 

If the emails are different (chen vs john)
then
1 - send email to chen
2 - update txt_email to john
3 - build NEW email body string

Userlevel 6
Badge +16

First time run
Set txt_EmailPrevious to “chen” email  - My post gets block when I type “chen” email in full !!

 

First Run
Compare txt_EmailPrevious var to current email value. result is TRUE
If TRUE, build the email body string.

Second, Third Run
Compare txt_EmailPrevious var to current email value. result is TRUE
If TRUE, append / build the email body string.

Forth Run
Compare txt_EmailPrevious var to current email value. result is FALSE
1) Send email to “chen” or txt_EmailPrevious
2) Set txt_EmailPrevious to “john” email
3)  build NEW email body string.

Userlevel 1
Badge +7

Thanks vm Garrett. I understand the logic but not sure how to implement the comparison. So currently I have this Run if True within Loop for each email, how do i store the previous email? Is it within Run if true? I am getting email each time not just one email.

Userlevel 6
Badge +16

 

Userlevel 1
Badge +7

Hi @Garrett thanks vm, apologies it is possibly beyond your scope of support, do you mind sharing with me your jsaon for the email?

Userlevel 1
Badge +7

Also i think under this setting, the recipient will receive multiple emails as it is within the loop?

Userlevel 6
Badge +16

What we are trying to do is to extract the first email before we enter the For-Each loop 

 

The Get Item from Collection:
Target Collection: Output from Query List → Items
Index: 0   
Store Item: obj_Item0 

 

The JSON Query:
JSON Path: obj_Item0
JSONPath Expression: Email_Email
Store First Result: txt_EmailPrevious

 

JSONPath Expression → <SPO Column>_Email
The SPO Column name might differ depending how you name the column. 
As the SPO Column is a people-type column the following fields are also available
<SPO Column>_DisplayName, <SPO Column>_ID

 

Email2 var contain the current record email value.
Email1 refers to txt_EmailPrevious

The Condition Branch compares Email1 (txt_EmailPrevious) is equal to Email2

 

Also i think under this setting, the recipient will receive multiple emails as it is within the loop?

Yes, there is a possibility because you are sorting by PRIORITY,  

 

If your Query List is sorted by Email
Then you could build 2 (or more) separate email Message body

 

Forth Run
Compare txt_EmailPrevious var to current email value. result is FALSE
0) Combine the Email body -> (High Priority + Low Priority) 

1) Send email to “chen” or txt_EmailPrevious
2) Set txt_EmailPrevious to “john” email
3) Reset the High-Priority and Low-Priority Email Message string or var to blank string “” 
     build NEW email body string.

 

This should solve your issue unless you have further unstated requirements (which you should put into a new thread)

Userlevel 1
Badge +7

Hi @Garrett Thanks vm for your help. I tried to follow your instructions and it seems all good except that only the first user (Chen in your example above) would be able to receive all outstanding items but not the other users - they would only receive one item in the email only but never the combined msg. Is it to do with my NEW email body string?

  1. in the first email (email 1) set up (before loop for each), i set up the previous email using query JSON
  2. Then within Loop for each i set up email 2 = Loop for each - Current item - email
  3. If the email 2 is equal to email 1, build up email body string (i assume there will always be multiple msg sent out instead of one combined msg to the same email address?)
  4. if the email in 2 is NOT equal to email 1, set a variable where previous email (email 1) = email 2 and reset msg body to empty (in the reset msg) and save the result to replace the msg if select yes

 

Can you please help me with it?

Userlevel 1
Badge +7

 Hi @Garrett 

I found a way to do it successfully by using two loops and run if true action

  1. create a list with emails only (list 1) and loop for each
  2. within the loop for each above, create another loop for each for the email (list 2 with priority and other information) that matches the above list
  3. run if true if the email matches and create email msg
  4. send email outside the list 2 loop for each
  5. clear msg after the email is sent

in this way, each person will receive their priories respectively without duplication/missing items.

attaching my workflow for future reference

 

Reply