Skip to content

EmailManager is not supported, throws exception #3433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
jfversluis opened this issue Jun 30, 2022 · 12 comments
Open
2 tasks done

EmailManager is not supported, throws exception #3433

jfversluis opened this issue Jun 30, 2022 · 12 comments
Labels
bug Something isn't working feature proposal maui-7.x Bugs targeted for maui-7.x theme-UwpParity

Comments

@jfversluis
Copy link
Member

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

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@nomadedge
Copy link

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

@nomadedge
Copy link

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)"

@castorix
Copy link

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

@mattleibow
Copy link

This is our PR to replace the UWP/WinUI APIs with MAPISendMail: dotnet/maui#10063

@mattleibow
Copy link

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

@evelynwu-msft evelynwu-msft added the maui-7.x Bugs targeted for maui-7.x label Dec 10, 2022
@jeanplevesque
Copy link

I know that it's currently not working, but would EmailManager be the correct API choice to send emails from a WinUI 3 app?
(Underlying SO question)

@castorix
Copy link

I know that it's currently not working, but would EmailManager be the correct API choice to send emails from a WinUI 3 app? (Underlying SO question)

MAPI works with WinUI 3 (at least on my OS, Windows 10 22H2)

@Soap-141
Copy link

Soap-141 commented Jan 30, 2023

@castorix Tried it on my side with MAUI Essentials and doesn't work.
See this for more details.

@castorix
Copy link

castorix commented Jan 30, 2023

@castorix Tried it on my side with MAUI Essentials and doesn't work. See this for more details.

I tested 2 methods, with IDataObject and IDropTarget with Guid "9E56BE60-C50F-11CF-9A2C-00A0C90A90CE" which simulates Explorer Right-Click on a File + [Sent to] [Mail recipient]
and by loading dynamically MAPISendMail from the right MAPI32.DLL with similar code as SDK function LoadDefaultMailProvider from "MapiUnicodeHelp.h"
(Windows App SDK 1.1.0, Windows 10 22H2)

@castorix
Copy link

castorix commented Feb 6, 2023

I just uploaded a test sample using MAPI + other usual methods to send mails : WinUI3_SendMail

@Soap-141
Copy link

Soap-141 commented Feb 6, 2023

Thanks @castorix I'll take a look at it.

@evelynwu-msft evelynwu-msft transferred this issue from microsoft/microsoft-ui-xaml Feb 14, 2023
@Muzzammils
Copy link

Muzzammils commented Aug 26, 2023

@jfversluis As a last resort for the time being, this works in a WinUI3 app,
await Windows.System.Launcher.LaunchUriAsync(new Uri("mailto:[email protected]?subject=subject"))

@codendone codendone removed the feature label May 23, 2024
@RDMacLachlan RDMacLachlan added this to the Future (backlog) milestone Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature proposal maui-7.x Bugs targeted for maui-7.x theme-UwpParity
Projects
None yet
Development

No branches or pull requests