Xamarin iOS - cant able to send an email other than Mail App.

Uragonda, Rajesh 31 Reputation points
2022-05-04T17:41:33.673+00:00
await Launcher.OpenAsync(new Uri("mailto:" + email));

Using the above snippet on ios, by default it opens the Mail app, if mail app is not installed it shows a pop up to download Mail app from playstore.

My requirement is to send an email with any email app such as Gmail, outlook or any other application installed on phone.

On Android it shows all the installed email applications as expected.

Is there any solution for ios to allow the user to send an email using any email application?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2022-05-05T05:53:05.97+00:00

    Hello,

    Xamarin.Essentials.Launcher enables your app to open a URI by system. From the source code, we can see that it uses UIApplication.CanOpenUrl(NSUrl) method in iOS. Your uri is "mailto:" + email, it starts with mailto:, it means that your app only could open Mail in your iOS device by system. If Mail is not installed, a prompt box will pop up asking whether to download Mail, which is a system behavior.

    My required is to send an email with any email app such as Gmail, outlook or any other application installed on phone.

    If you want to open other apps, you need to specify LSApplicationQueriesSchemes in your Info.plist file. Scheme name of Microsoft Outlook is ms-outlook, and you can open Outlook by await Launcher.OpenAsync(new Uri("ms-outlook://XXXXXX"));. But if you haven't installed this app, it won't pop up the prompt to download automatically, you need to open the download page in App Store : await Launcher.OpenAsync(new Uri("itms-apps://apps.apple.com/us/app/microsoft-outlook/id951937596"));
    Refer to

     bool canopen = await Launcher.CanOpenAsync(new Uri("ms-outlook://XXX"));  
                if (canopen)  
                {  
                    await Launcher.OpenAsync(new Uri("ms-outlook://XXX"));  
                     
                }  
                else {  
                    await Launcher.OpenAsync(new Uri("itms-apps://apps.apple.com/us/app/microsoft-outlook/id951937596"));  
                }  
    

    You can also open other apps if you have set the scheme name and customize the URI, please search for the URLs you're interested in to LSApplicationQueriesSchemes.

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.