How can I open default email app with main window not the send window?

eduardk 46 Reputation points
2021-01-15T12:42:49.247+00:00

I want the user go to inbox and read the incoming message.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 72,336 Reputation points Microsoft Vendor
    2021-01-15T13:08:38.83+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

       public interface IOpenManager  
       {  
           void openMail();  
       }  
    

    In Android.

       [assembly: Dependency(typeof(OpenImplementation))]  
       namespace App23.Droid  
       {  
           public class OpenImplementation : IOpenManager  
           {  
               public void openMail()  
               {  
                   Intent intent = new Intent(Intent.ActionMain);  
                   intent.AddCategory(Intent.CategoryAppEmail);  
                   intent.AddFlags(ActivityFlags.NewTask);  
                   //FLAG_ACTIVITY_NEW_TASK  
                   Android.App.Application.Context.StartActivity(intent);  
               }  
           }  
       }  
    

    In iOS.

       [assembly: Dependency(typeof(OpenImplementation))]  
       namespace App23.iOS  
       {  
           public class OpenImplementation : IOpenManager  
           {  
               public void openMail()  
               {  
                   NSUrl mailUrl = new NSUrl("message://");  
                   if (UIApplication.SharedApplication.CanOpenUrl(mailUrl))  
                   {  
                       UIApplication.SharedApplication.OpenUrl(mailUrl);  
                   }              
               }  
           }  
       }  
    

    call this dependcy via: DependencyService.Get<IOpenManager>().openMail();

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful