In order to dynamically create the link all we have to do is read the manifest file, get the "ProductID" attribute value, and then create the link with the expected format; with this data, we can write a class in C# such as this:
The most important part of this class is the GetManifestAttributeValue(string) function, that will access the WMAppManifest.xml file and from there retrieve the required information.
Once we have the ApplicationId, we will then use it along the BuildApplicationDeepLink(string) function to return the final link!
Now all we have to do is add this class to our project and then invoke the DeepLinkHelper.BuildApplicationDeepLink() function to retrieve the application deep link, and do with it whatever we'd like (send by email, share on social networks, ...)!.
Fig: WMAppManifest.xml attributes description
For details of WMAppManifest.xml file attributes you can visit : http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769509(v=vs.105).aspx. Test this code: To see if the above code works or not, simply download my application in which it is implemented. : http://www.windowsphone.com/s?appid=40787769-adab-4ef3-a820-1cf2ec042bcc