cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

how to send the data generated by Dataexport widget in email

Ujwal17
7-Bedrock

how to send the data generated by Dataexport widget in email

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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

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

slangley
23-Emerald II
(To:Ujwal17)

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

Top Tags