Skip to main content
1-Visitor
March 17, 2020
Solved

how to send the data generated by Dataexport widget in email

  • March 17, 2020
  • 3 replies
  • 1192 views

I am trying to send the file generated by data export widget in email. How to do this?

Best answer by Constantine

Hello,

 

The widget is executed in the user's browser, but you send emails on the server side. If you need to send CSV files as emails, I would recommend abandoning the widget path and consider the following sequence instead:

  1. The user presses "Export" button in the mashup, this triggers some Export() service on the server side
  2. In this service you get the required query, which returns you an INFOTABLE, which you then parse to convert into a CSV file. You can use CreateTextFile / AppendToTextFile services defined on FileRepository things to create such file. You can use generateGUID() to generate unique random filename.
  3. At the end of this Export service you execute SendMessage() service on your MailServer thing (check ThingWorx Help and this forum if you need help configuring it). You specify the generated CSV file as email attachement in one of SendMessage parameters.
  4. Finally, you cleanup by deleting the CSV file.

If you need to download the CSV file in addition to emailing it, then instead of (4) you can return the complete filename and use it as URL for WebFrame widget on your mashup. This will trigger the download after the email has been sent. In this case make sure that you have some scheduled job which cleans up those temporary files every night for example.

 

Regards,
Constantine

3 replies

raluca_edu
17-Peridot
March 17, 2020

Hi,

 

Unfortunately, a click event that would help sending the file by email for Data Export widget is not available.

Please check this article: https://www.ptc.com/en/support/article/CS225499

 

 

Hope it helps,

Raluca Edu

18-Opal
March 17, 2020

Hello,

 

The widget is executed in the user's browser, but you send emails on the server side. If you need to send CSV files as emails, I would recommend abandoning the widget path and consider the following sequence instead:

  1. The user presses "Export" button in the mashup, this triggers some Export() service on the server side
  2. In this service you get the required query, which returns you an INFOTABLE, which you then parse to convert into a CSV file. You can use CreateTextFile / AppendToTextFile services defined on FileRepository things to create such file. You can use generateGUID() to generate unique random filename.
  3. At the end of this Export service you execute SendMessage() service on your MailServer thing (check ThingWorx Help and this forum if you need help configuring it). You specify the generated CSV file as email attachement in one of SendMessage parameters.
  4. Finally, you cleanup by deleting the CSV file.

If you need to download the CSV file in addition to emailing it, then instead of (4) you can return the complete filename and use it as URL for WebFrame widget on your mashup. This will trigger the download after the email has been sent. In this case make sure that you have some scheduled job which cleans up those temporary files every night for example.

 

Regards,
Constantine

Support
March 25, 2020

Hi @Ujwal17.

 

If one of the previous responses allowed you to find a solution, please mark the appropriate one as the Accepted solution for the benefit of others with the same issue.

 

Regards.

 

--Sharon