0

I am trying to figure out how to make a SharePoint workflow send a email containing specific Excel data from a file on this respective SharePoint. Maybe there is a far better way, i do not know.

For example: there is the file on SharePoint called ExampleTable.xlsx containing table: A,B,C we have a recipient's mail: example.recipient@domain.org

Everytime a respective user applied changes to ExampleTable.xlsx, especially to the contained tables, the recipient should receive a mail with the following content:

Filename, Date of modification

Table A

Table B

Table C

Where the tables should represent a encoded table view.

A even more sophisticated problem is that the ExampleTable.xlsx may aqquire additional data from other sourcen, just in time.

I face a problem evaluating such a kind of procedure.

Hopefully there is one expert in this topic arround there =)

I would also be satisfied if you can provide evidence that this is not possible with the given systems.

0

The Key to the Solution is the SharePoint REST API. This API provides the possibility to query content of documents inside of SharePoint.

According to automatically sent mail: We create List Workflows in SharePoint Designer.

After a document in a specific list was created or changed (thats my preference, you also can catch other events) -> Send a triggered mail.

Now the clue:

You have to edit the HTML Code of the mail, which is created by the workflow, with the Rest API Query.

A Query looks like this

https://start.domain.end/sites/page/_vti_bin/ExcelRest.aspx/internal/sharepoint/path/to/your/file/TargetFile.xlsx/Model/Ranges('SomeNameSpaceDefined')?$format=IMAGE

This link will return a picture of the queried data of the namespace "SomeNameSpaceDefined".

It is handled as a picture, hence most reliable mail service clients permit other ways like embedding the response in an iframe.

The raw HTML example mail template in our SharePoint Workflow would look like this.

<html>
<body>

<img src="https://start.domain.end/sites/page/_vti_bin/ExcelRest.aspx/internal/sharepoint/path/to/your/file/TargetFile.xlsx/Model/Ranges('SomeNameSpaceDefined')?$format=IMAGE" style="border:none"></img>

</body>
</html>

Now you can also Specify the path to the file in the img src link with the SharePoint Global variables like -> [%Current Item:Server Relative URL%]

It is very interesting hence you can also build dynamic queries. An example would be the automatic creation of a newsletter, according to data specified in an Excel file. You will declare namespaces with the name of the current date and link them between the Workflow, RestAPI and the source Excel File.

Another example for a query would be to request a specific Range, hence you may not use namespaces:

https://start.domain.end/sites/page/_vti_bin/ExcelRest.aspx/internal/sharepoint/path/to/your/file/TargetFile.xlsx/Model/Ranges(‘Sheet2!A1|D4’)?$format=IMAGE

As you can see the syntax really differes from the usual Excel syntax. Thats because we collide with URL en/decoding guidelines.

Another interesting annotation is: you can also specifiy the format as desired.

Available: $format=IMAGE, $format=HTML, $format= ATOM

Hope this helps in future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.