Reputation: 20909
For our Application, we have a custom uri handler, which allows to open some views inside the application from external sources (i.e. app://viewProduct/225545568
)
This is working fine, hower when such a link is pasted inside an Email, Outlook does not turn it into a "clickable" link.
HKEY_CURRENT_USER\Software\Classes\app
, so calling it from WIN + R brings up the application perfectly fine. Is there a way, that Outlook can understand (registered) URIs to turn them into HyperLinks
automatically? (Or would we need to deploy some sort of firmwide macro to make this happen?)
Upvotes: 0
Views: 1587
Reputation: 20909
Heres a workaround that worked out perfectly fine:
I'm still searching for a proper solution, just wanted to leave this woraround "here" already.
After some research, I found out that Outlook by default links a certain amount of "protocols" (Hardcoded): So I attempted to register "my" application with the mms
-protocol, which we don't need inside a Business-Environment.
Deleted first try, as only applicable for Windows 7
So I played around a little more and figured out, that the following keys are required for Windows 7 and Windows 10 to get things rolling.
Note: For Windows 10, this will only "enroll" your application as a suitable default application for the protocol. You have to manually assign the application, using "Windows 10's Default App -> By Protocol"-Menu. (As long as this applies for Chrome - so Google-Devs don't have a workaround - I don't spend any minute on this :P )
The Good News: Setting all the keys on any system doesn't seem to cause any problem. (So let's ignore that little bit of registry polution :-) )
Use on your own risk - my tests are positve in a very narrow minded environment.
Replace Config.MyApplicationURLHandler
with your executable, i.e. C:\Path\To\Executable %1
Replace MyApplication
with your application name.
private void RegisterMyProtocol()
{
//Step 1: Register for the MMS-Protocol.
//Thats some media plaer stuff, we don't need at all.
//We use this, because it will be autolinked in Outlook / word / excel.
RegistryKey key = CreateRegistryChain(Registry.CurrentUser, "Software/CLASSES/mms");
key.SetValue(string.Empty, "URL:mms Protocol");
key.SetValue("URL Protocol", string.Empty);
key.Close();
key = CreateRegistryChain(Registry.CurrentUser, "Software/CLASSES/mms/shell/open/command");
key.SetValue(string.Empty, Config.MyApplicationURLHandler);
key.Close();
//Step 2: Create required entries for windows 10.
//NOTE: Win 10 Users need to select Uri-Schemes manually.
key = CreateRegistryChain(Registry.CurrentUser, "Software/CLASSES/mms/shell/open/command");
key.SetValue(string.Empty, Config.MyApplicationURLHandler);
key.Close();
key = CreateRegistryChain(Registry.CurrentUser, "Software/MyApplication/Capabilities");
key.SetValue("ApplicationDescription", "MyApplication");
key.SetValue("ApplicationName", "MyApplication");
key.Close();
key = CreateRegistryChain(Registry.CurrentUser, "Software/MyApplication/Capabilities/URLAssociations");
key.SetValue("mms", "mms");
key.Close();
key = CreateRegistryChain(Registry.CurrentUser, "SOFTWARE/RegisteredApplications");
key.SetValue("MyApplication", "Software\\MyApplication\\Capabilities");
key.Close();
//Step 3: Remove the original UrlAssociation.
key = CreateRegistryChain(Registry.CurrentUser, "SOFTWARE/Microsoft/Windows/Shell/Associations/UrlAssociations");
if (key.GetSubKeyNames().Contains("mms"))
{
key.DeleteSubKey("mms");
}
key.Close();
}
private RegistryKey CreateRegistryChain(RegistryKey root, String keyChain){
String[] keys = keyChain.Split('/');
foreach(String key in keys)
{
if (!root.GetSubKeyNames().Contains(key))
{
root.CreateSubKey(key, true);
}
root = root.OpenSubKey(key, true);
}
return root;
}
Note: By default the mms-Protocol causes Outlook to display a security warning. So either add the Protocol to your trusted Protocols through the GPO, or by using the registry key:
(Where the version 16.0 needs to match your Outlook version)
HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\Common\Security\Trusted Protocols\All Applications\mms:
If some keys don't exist just Create them.
Don't forget to sanitize inputs within your application, as we don't want to handle the real stuff which uses the mms
-protocol. :-)
Upvotes: 1