microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

`EmailManager` is not supported, throws exception

Open jfversluis opened this issue 3 years ago • 3 comments

Describe the bug

Depending on how you look at it I guess this might also be a feature request. In .NET MAUI we have functionality that allows users to compose an email. For UWP we could use the code underneath to compose an email programmatically and present the user with a screen in their favorite email client to send the email.

using Windows.ApplicationModel.Email;
EmailMessage message = new();
// Add to, cc, attachments, body, etc.

await EmailManager.ShowComposeNewEmailAsync(message);

When calling this from WinUI, we are presented with an exception "The request is not supported. (0x80070032)"

I've tried exploring alternatives like using mailto: or resorting to MAPI. The latter might be what this functionality is based on, but that would mean we have to add a lot of code that might already live with you.

Steps to reproduce the bug

  1. Implement code that tries to call EmailManager, see above
  2. Run the code
  3. Observe the exception being thrown

image

Expected behavior

The functionality works as it did when running it through UWP which is: present the user with a compose email screen.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.1.1

Windows app type

  • [X] UWP
  • [X] Win32

Device form factor

Desktop

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

jfversluis avatar Jun 30 '22 11:06 jfversluis

Hi, any news on that one since MAUI is now released? Need email functionality in my application and encountered this bug

nomadedge avatar Aug 14 '22 06:08 nomadedge

https://docs.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service Tried this approach to run EmailManager under UWP, didn't help. Though text of exception is something different a bit: "The request is not supported. (Exception from HRESULT: 0x80070032)"

nomadedge avatar Aug 14 '22 17:08 nomadedge

For UWP we could use the code underneath to compose an email programmatically and present the user with a screen in their favorite email client to send the email.

MAPISendMail does that

castorix avatar Aug 14 '22 21:08 castorix

This is our PR to replace the UWP/WinUI APIs with MAPISendMail: https://github.com/dotnet/maui/pull/10063

mattleibow avatar Sep 27 '22 16:09 mattleibow

@evelynwu-msft this is part of the maui bug list :)

mattleibow avatar Nov 04 '22 00:11 mattleibow