Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 546
Matt Ward Avatar asked Oct 22 '25 05:10

Matt Ward


1 Answers

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.

like image 81
Martin Zikmund Avatar answered Oct 23 '25 21:10

Martin Zikmund



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!