0

I want to allow users to send a file from within my UWP app through their default email client. Currently, there is no way for UWP apps to attach files to any other email client besides Windows Mail. So, with that restriction, the next best thing I can do is determine which email client is set as default, and if it isn't Windows Mail, I can notify the user that they need to change their default or attach the file manually.

The standard way to get this information appears to be through Win32.Registry. There's a number of different places people have been pointing me to, but none of them appear to consistently hold the correct data (or even exist at all).

From this post:

HKEY_CURRENT_USER\Software\Clients\Mail -> Doesn't exist

HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail -> Is stuck as Microsoft Outlook, as described by this post.

From this post:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command -> Fixed as "C:\Program Files\Microsoft Office\Root\Office16\OUTLOOK.EXE" -c IPM.Note /mailto "%1"

HKEY_CURRENT_USER\SOFTWARE\Classes\mailto -> No data

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\mailto -> No data

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Roaming\OpenWith\UrlAssociations\mailto -> No data

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\mailto\UserChoice\ProgId -> This is the only value that updates when I change the default mail client. Here are some of the values:

Windows Mail: AppXydk58wgm44se4b399557yyyj1w7mbmvd
Outlook: Outlook.URL.mailto.15
Chrome: ChromeHTML

However, this location appears to require the user to run the app as an administrator, or else it throws an error.

Are any of these values consistent? Could I check in the app for this Windows Mail ProgId value, or does it totally vary by device? Is there somewhere else I should be looking, or a different approach I should be taking?

Thank you!

Pete
  • 1
  • 1
  • 2
  • Do you have to do it by this route? One way of solving a problem where the world is too wild, wacky and varied is to bring it under something you can control.. Like submitting the file and email they write to a web service you control. Tell us more about this email - what is it for? where does it go? what's the attachment for/content? – Caius Jard Oct 28 '21 at 20:25
  • Yeah, unfortunately. Without revealing the app directly (company software, not my own), the basic premise is that the app receives documents from a web service, and users can modify the documents through the app. Emailed documents can then be sent to other users. – Pete Oct 28 '21 at 20:44
  • I'm struck that it would seem more efficient and secure for these documents to be submitted back to a server via web service and then notification of documentation availability (a link) emailed to other users. This way you retain control of the documents, can serve them more securely, track changes and cope with simultaneous edits and keep an up to date single version- emailing the documents out doesn't seem to have any benefits overall unless it's some sort of legal thing where people need a copy; could they perhaps hit "email me this" after using the link, and the server sends the mail? – Caius Jard Oct 29 '21 at 05:43
  • This might be possible with our current architecture, but might be overkill for a small feature such as this one. As a security measure, we never store user data on any of our web servers, and users provide their own documents through their own document management service. We would have to store these modified documents on their server, with multiple versions (users can toggle on/off other user's changes), indefinitely. – Pete Oct 29 '21 at 17:50

0 Answers0