Get email messages in Xamarin

GemBox.Email is a standalone .NET component with cross-platform support. You can use it on non-Windows platforms and frameworks like Xamarin and Mono, enabling you to use it on Android and iOS mobile devices.

By using GemBox.Email you can process your email messages (send, receive, load, save, convert, and edit EML and MSG files) from the native mobile apps.

The following example shows how you can get the first email message from the INBOX using the ImapClient in Xamarin.Forms application.

Get email message on a native Android mobile app with Xamarin.Forms
Screenshot of Xamarin Android app that gets the first email message from inbox.
<ContentPage xmlns=""

    <StackLayout Padding="50" 
                 Spacing="20" >

        <Label Text="GemBox.Email Example"

        <Entry Placeholder="Imap host"
               Text="{Binding Host}" />

        <Entry Placeholder="User name"
               Text="{Binding Username}" />

        <Entry Placeholder="Password" 
               Text="{Binding Password}" />

        <ActivityIndicator x:Name="activity" />

        <Button x:Name="button"
                Text="Get message" 
                Clicked="Button_Clicked" HorizontalOptions="Fill" />

using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Xamarin.Forms;
using GemBox.Email;
using GemBox.Email.Imap;

public partial class MainPage : ContentPage
    private readonly DataModel model;

    public MainPage()


        model = new DataModel();
        BindingContext = model;

    private MailMessage GetMessage()
        using (var imap = new ImapClient(model.Host))
            imap.Authenticate(model.Username, model.Password);

            return imap.GetMessage(1);

    private async void Button_Clicked(object sender, EventArgs e)
        button.IsEnabled = false;
        activity.IsRunning = true;

            var message = await Task.Run(() => GetMessage());
            await DisplayAlert("Message",
                "\nSUBJECT: " + message.Subject +
                "\nFROM: " + message.From.ToString() +
                "\nDATE: " + message.Date.ToString(),
        catch (Exception ex)
            await DisplayAlert("Error", ex.Message, "Close");

        activity.IsRunning = false;
        button.IsEnabled = true;

public class DataModel
    public string Host { get; set; }
    public string Username { get; set; }
    public string Password { get; set; }
Imports System
Imports System.ComponentModel
Imports System.Threading.Tasks
Imports Xamarin.Forms
Imports GemBox.Email
Imports GemBox.Email.Imap

Partial Public Class MainPage
    Inherits ContentPage

    Private ReadOnly model As DataModel

    Public Sub New()


        model = New DataModel()
        BindingContext = model
    End Sub

    Private Function GetMessage() As MailMessage
        Using imap As New ImapClient(model.Host)
            imap.Authenticate(model.Username, model.Password)

            Return imap.GetMessage(1)
        End Using
    End Function

    Private Async Sub Button_Clicked(sender As Object, e As EventArgs)
        button.IsEnabled = False
        activity.IsRunning = True

            Dim message = Await Task.Run(Function() GetMessage())
            Await DisplayAlert("Message",
                "\nSUBJECT: " + message.Subject &
                "\nFROM: " + message.From.ToString() &
                "\nDATE: " + message.Date.ToString(),
        Catch ex As Exception
            Await DisplayAlert("Error", ex.Message, "Close")
        End Try

        activity.IsRunning = False
        button.IsEnabled = True
    End Sub
End Class

Public Class DataModel
    Public Property Host As String
    Public Property Username As String
    Public Property Password As String
End Class

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Email yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.