Solved

Send an email with list items

  • 9 June 2023
  • 7 replies
  • 262 views

Badge +3

Hi, 

I would like to create a scheduled workflow to gather the items that have been added to a Sharepoint List on the current day, insert it into an email as a table, then send to recipients. 

Thanks in advance!

icon

Best answer by Garrett 9 June 2023, 08:30

View original

7 replies

Userlevel 6
Badge +16

Hi @ItsGavin 

Just to clarify your requirements

You want items that has been add → Does this mean just new List Items that has been created or also include updated List Items
New List Item → Query condition is Created field (DateTime Type)
Update List Items → Query condition is Modified field (DateTime Type)
Remove the second condition of you don’t need it.
Output variable is “SPO Query

 

You stated “insert it into an email as a table” → What is it? The item ID or the entire row of details?
You will need to create a For Each Loop using the output from the previous Query
SPO Query → Items 

Append the retrieve value into the HTML table using the Create String action.
Here we are adding one row of record. We include the ID, Created By and Create field (pls feel free to add or remove the fields

This code is just partial HTML Table. We have to finalize it with another Create String action outside the for each loop

 

You can include the variable txt_HTMLTable into the email content body.

 

The basic Workflow. Opps forgot the Send Email action at the end

 

Badge +3

@Garrett as per usual, you have solved all my issues! Thank you so so much! 

I do have 2 follow up questions:

In the SPO Query, I set “Created is on Current Date” it doesn't show any results, however, if I set it to “Created is before Current Date” it shows all results. How can I get it to only show results from today? 

Secondly, how can I get headers in the table?

Thank you!

Userlevel 6
Badge +16

Hi @ItsGavin 

For Date Comparison, what you think is date has actually 2 components the Date and the Time.

Many people are or get confuse Created is on Current Date

Created → Date Value is 1-Jun, Time is 10am
Current Date → Date Value is 1-June and Time is 12:00:00 am (00:00.00 am) HH:MM:SS

As such, usually NO results is return

 

 

More accurately if you wanted all items on 1-Jun, items would be in the range of 

1-June 12:00:00am and 2-June 12:00:00am 

 

 

Userlevel 6
Badge +16

For Table Headers, just add the orange colour text when you finalize the table

 

<table>
  <tr>
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
  </tr>

[txt_HTMLTable]

</table>

 

Badge +3

@Garrett this all makes so much sense! Thank you again!

Badge +3

Hi @ItsGavin 

For Date Comparison, what you think is date has actually 2 components the Date and the Time.

Many people are or get confuse Created is on Current Date

Created → Date Value is 1-Jun, Time is 10am
Current Date → Date Value is 1-June and Time is 12:00:00 am (00:00.00 am) HH:MM:SS

As such, usually NO results is return

 

 

More accurately if you wanted all items on 1-Jun, items would be in the range of 

1-June 12:00:00am and 2-June 12:00:00am 

 

 

I have been wracking my head trying to find out how to do the date range.. But I just can’t work it out. Do you (or anyone else) have any tips please? :)

Userlevel 6
Badge +16

Here’s how to create the 2 date variables for a today date comparison 
Notice that the time portion is all zeros

Search for date items in the range between dt_CurrentDate and dt_NextDay.

 

Reply