<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: email link to file in a repository in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1028533#M70280</link>
    <description>&lt;P&gt;The server does not know the URL itself. You have to set it somewhere manually and adapt it for each instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Our best practice is to create an "Environment"-Thing with a &lt;A href="https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Composer/ConfigurationTables.html#wwID0EM1JV" target="_blank"&gt;ConfigurationTable&lt;/A&gt; which holds different useful values like hostname, envName, sendEmails,.. These can be then used by different UseCases to get the information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your service you would then do a&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;let link = "https://"+ Things["EnvironmentThing"].GetConfigTable().hostName + fileInfo.downloadLink; // (pseudocode)&lt;/LI-CODE&gt;
&lt;P&gt;but you can also use a property or something else to store the information. (But properties may change value on extension update, so configtable is our prefference).&lt;/P&gt;</description>
    <pubDate>Fri, 08 Aug 2025 16:12:25 GMT</pubDate>
    <dc:creator>nmutter</dc:creator>
    <dc:date>2025-08-08T16:12:25Z</dc:date>
    <item>
      <title>email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1028519#M70278</link>
      <description>&lt;P&gt;I'm using&amp;nbsp;&lt;SPAN&gt;ThingWorx 9.3.9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My service creates a file in a file repository.&amp;nbsp; I would then like the service to email a link to the file that the user can click on to download the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using the repository's GetFileListingWithLinks service that returns an infotable that has a hyperlink field named downloadLink.&amp;nbsp; However, the value that is returned is in this format:&lt;/P&gt;&lt;P&gt;/Thingworx/FileRepositories/MLLC.Common.Repository/LineZRouteID_2025-08-07.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I email that value Outlook does not recognize that value as a link.&amp;nbsp; So, I think I need to somehow convert it to this format:&lt;/P&gt;&lt;P data-unlink="true"&gt;http://thingworxu15/Thingworx/FileRepositories/MLLC.Common.Repository/LineZRouteID_2025-08-07.csv&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Here's my code.&amp;nbsp; The commented lines show the ways I tried to get it to email a proper link.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// result: INFOTABLE dataShape: "FileSystemFileWithLinks"
		let fileInfo = Things["MLLC.Common.Repository"].GetFileListingWithLinks({
			path: "/" /* STRING */ ,
			nameMask: validationID + "_" + formattedDate + ".csv" /* STRING */
		});
		//linkToCSV = "&amp;lt;a href=" + fileInfo.downloadLink + "&amp;gt;&amp;lt;/a&amp;gt;";
        //linkToCSV = "&amp;lt;a href=" + fileInfo.downloadLink.toString() + "&amp;gt;&amp;lt;/a&amp;gt;";
        //linkToCSV = fileInfo.downloadLink.removeAttribute('href');
        linkToCSV = fileInfo.downloadLink;
         
        let body = "&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;" + linkToCSV + "&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;";

		// send message
		Things[me.emailThingName].SendMessage({
			cc: undefined /* STRING */ ,
			bcc: undefined /* STRING */ ,
			subject: validationID + " Updates Needed" /* STRING */ ,
			from: undefined /* STRING */ ,
			to: emailList /* STRING */ ,
			body: body /* HTML */
		});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this is what I get - no link.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="steve237_1-1754664375757.png" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/126763i35A9ECDCDE9BF71E/image-size/large?v=v2&amp;amp;px=999" role="button" title="steve237_1-1754664375757.png" alt="steve237_1-1754664375757.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that I can build the link, but that would require the code to be updated with the new host as we move from Dev to Test to Production.&amp;nbsp; Something, I'd like to avoid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 14:50:47 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1028519#M70278</guid>
      <dc:creator>steve237</dc:creator>
      <dc:date>2025-08-08T14:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1028533#M70280</link>
      <description>&lt;P&gt;The server does not know the URL itself. You have to set it somewhere manually and adapt it for each instance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Our best practice is to create an "Environment"-Thing with a &lt;A href="https://support.ptc.com/help/thingworx/platform/r9.5/en/#page/ThingWorx/Help/Composer/ConfigurationTables.html#wwID0EM1JV" target="_blank"&gt;ConfigurationTable&lt;/A&gt; which holds different useful values like hostname, envName, sendEmails,.. These can be then used by different UseCases to get the information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your service you would then do a&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;let link = "https://"+ Things["EnvironmentThing"].GetConfigTable().hostName + fileInfo.downloadLink; // (pseudocode)&lt;/LI-CODE&gt;
&lt;P&gt;but you can also use a property or something else to store the information. (But properties may change value on extension update, so configtable is our prefference).&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 16:12:25 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1028533#M70280</guid>
      <dc:creator>nmutter</dc:creator>
      <dc:date>2025-08-08T16:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1029074#M70314</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/290882"&gt;@steve237&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;BR /&gt;Have you considered using:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;"IPAddress = Resources[&lt;SPAN style="color:rgb(33,145,97);font-size:16px !important;"&gt;"CurrentSessionInfo"&lt;/SPAN&gt;].GetCurrentIPAddress();"&lt;BR /&gt;&lt;BR /&gt;This does not get the entire URL but it does get part. There are 2 items which I think you might be missing.&lt;BR /&gt;The protocal: "http" or "https"&lt;BR /&gt;The port number would be the other item which you seem to be missing.&lt;BR /&gt;I am checking to see if that is available?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;pehowe&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 18:47:54 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1029074#M70314</guid>
      <dc:creator>PEHOWE</dc:creator>
      <dc:date>2025-08-12T18:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1029075#M70315</link>
      <description>Https won’t work with an IP address.&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Aug 2025 18:51:31 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1029075#M70315</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2025-08-12T18:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1030119#M70345</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/290882"&gt;@steve237&lt;/a&gt;&lt;/SPAN&gt; ,&lt;BR /&gt;I did a little example and using http worked.&lt;BR /&gt;Please review the information presented and let me know if you have any questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pehowe&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2025 19:47:58 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1030119#M70345</guid>
      <dc:creator>PEHOWE</dc:creator>
      <dc:date>2025-08-19T19:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1030125#M70346</link>
      <description>&lt;HTML&gt;
 &lt;HEAD&gt;
 &lt;/HEAD&gt;&lt;BODY&gt;
  &lt;SPAN&gt;Do you suggest them using plain unencrypted http in production? This won’t work with httpS because their TLS certificates will be issued for domain names, not for IP addresses.&lt;/SPAN&gt;
  &lt;BR /&gt;
  &lt;DIV&gt;
   &lt;BR /&gt;
  &lt;/DIV&gt;
 
&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Aug 2025 20:17:37 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1030125#M70346</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2025-08-19T20:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1031935#M70440</link>
      <description>&lt;P&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/302903"&gt;@PEHOWE&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks, but when I tried using your suggestion (&lt;SPAN&gt;IPAddress = Resources[&lt;/SPAN&gt;&lt;SPAN&gt;"CurrentSessionInfo"&lt;/SPAN&gt;&lt;SPAN&gt;].GetCurrentIPAddress();)&amp;nbsp; it returned the IP address of my laptop, not the server,&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Sep 2025 03:03:04 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1031935#M70440</guid>
      <dc:creator>steve237</dc:creator>
      <dc:date>2025-09-02T03:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: email link to file in a repository</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1037041#M70664</link>
      <description>&lt;P&gt;Hello &lt;SPAN style="color:var(--ck-color-mention-text);"&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/290882"&gt;@steve237&lt;/a&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have looked into this issue. &amp;nbsp;The ThingWorx function "GetFileListingWithLinks" Builds the end of a URL to access a file.&amp;nbsp;&lt;BR /&gt;The question you ask is in ThingWorx, can click on this link and it provides the requested file. When you tried to send that information in an EMail, the link is no longer complete. &amp;nbsp; &amp;nbsp;When in ThingWorx the results of the function "GetFileListingWithLinks" are passed to the Tomcat instance. The Tomcat instance, then adds the protocol and FQDN.&lt;BR /&gt;&lt;BR /&gt;There is no method in ThingWorx to get the Protocal and Fully Qualified Domain Name (FQDN) for the ThingWorx instance.&lt;/P&gt;
&lt;P&gt;The only solution is to build this information from you code.&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The function I suggested to the the IP address is also not going to be of any help for your case.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;
&lt;P&gt;Pehowe&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 18:41:26 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/email-link-to-file-in-a-repository/m-p/1037041#M70664</guid>
      <dc:creator>PEHOWE</dc:creator>
      <dc:date>2025-10-06T18:41:26Z</dc:date>
    </item>
  </channel>
</rss>

