This demo project demonstrates how to launch Outlook from a UWP application.
UWP already comes with the possibility to open a mail dialog with the mail app of your choice. However - until this day - attachments will vanish if Outlook is selected as mail client.
Outlook mails can be saved to *.msg files. Opening an *.msg file will launch the "new mail" window of outlook with subject, body text, recipients etc. already prefilled. Attachments can also be part of an *.msg file.
This demo creates such an *.msg file (using MsgKit) inside of the local cache folder and will launch it from within the UWP app.
That's already all there is to it. 😅
Usually Outlook can be opened using the Microsoft.Office.Interop.Outlook
namespace. This, however, is not possible from within a UWP application as it runs inside a sandbox and is not allowed to communicate with other non-app programs.
The only workaround you can find online makes use of the FullTrustProcessLauncher
. This solution, however, is a pain to implement and will also result in three different projects - only to launch an Outlook instance.
The solution I present is both simple to implement and will not affect the rest of your project.