简体   繁体   中英

Open mail app without creating email draft

I have an app that needs to prompt the user to open an email that's just been sent to them. It would be a great feature if it automatically opened the email app for them.

I currently have this code to open the email app and create a new draft email:

Device.OpenUri(new Uri("mailto://"));

I need this to run without opening a new email, just take them to their default mail app.

This is not possible to do in a purely cross-platform manner without the mailto:// URI which all systems understand. If you wanted to just open the mail client, you would have to check if your target OS supports such intent / URI and open it in a platform-specific manner.

Update: I have found platform specific solutions for Android and iOS.

Android

var intent = PackageManager.GetLaunchIntentForPackage("com.android.email");
StartActivity(intent);

iOS

UIApplication.SharedApplication.OpenUrl("message://");

UWP

In case of UWP mailto: seems to be the right option according to Docs . Unfortunately from my testing it does try to create a new e-mail with the built in Outlook Mail app. I will report that as a issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM