Sending An Email From The App Using Email Composer Task


In this article we will learn about compoisng email. We will see how to send email from our app using the Windows Mail app. For that purpose we will use a Windows Phone task launcher. The good thing about this launcher is it's very simple to use and can be integrated into an app with just 4-5 lines of code. So let's start.

Email Compose Task

This is a kind of launcher provided by Windows Phone to launch mobile email apps. In case of multiple accounts or mailing apps, the user is provided with an option to select the desired one. The email compose task helps to easily integrate a mobile mail service with other apps. It can be used for various purposes, like feedback, suggestions, problem reporting and so on.

Before using this task we need to include the following namespace:

using Microsoft.Phone.Tasks;

This task has the following properteys that we can use:

  • BCC
    Gets or sets the BCC text of an email.
  • CC
    Gets or sets the CC text of an email.
  • Subject
    Gets or sets the subject of an email.
  • To
    Gets or sets the recipients of an email.
  • Body
    Gets or sets the Body text of an email.












    FontFamily="{StaticResource PhoneFontFamilyNormal}"

    FontSize="{StaticResource PhoneFontSizeNormal}"

    Foreground="{StaticResource PhoneForegroundBrush}"

    SupportedOrientations="Portrait" Orientation="Portrait"



    <!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">


            <RowDefinition Height="Auto"/>

            <RowDefinition Height="*"/>



        <!--TitlePanel contains the name of the application and page title-->

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

            <TextBlock Text="Demo" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>

            <TextBlock  Text="Demo" Margin="9,-7,0,0" FontSize="40" />



        <!--ContentPanel - place additional content here-->

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <StackPanel Orientation="Vertical">

                <TextBox Name="bccTxt" Text="BCC Here"></TextBox>

                <TextBox Name="ccTxt" Text="CC Here"></TextBox>

                <TextBox Name="subTxt" Text="Subject Here"></TextBox>

                <TextBox Name="toTxt" Text="To: "></TextBox>

                <TextBox Name="bodyTxt"  Text="Your Mail Text" Height="285"></TextBox>

                <Button Name="sendBtn" Click="send" Content="Send" HorizontalAlignment="Left" Width="186" Height="80" VerticalAlignment="Bottom" Margin="132,0,0,0"/>





C# Code Behind

using Microsoft.Phone.Controls;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Diagnostics;

using Microsoft.Phone.Tasks;

using System.Windows.Media;


namespace Demo


    public partial class MainPage : PhoneApplicationPage


        // Constructor

        public MainPage()





        private void send(object sender, RoutedEventArgs e)


            /* Step 1 */

            Microsoft.Phone.Tasks.EmailComposeTask emt = new EmailComposeTask();

            /* Step 2 */

            emt.Bcc = bccTxt.Text;

            emt.Cc = ccTxt.Text;

            emt.Subject = subTxt.Text;

            emt.To = toTxt.Text;

            emt.Body = bodyTxt.Text;

            /* Step 3 */





The show method is used to launch the task. The email will be sent only after the user clicks on the send button of the email app launched by the task.





Up Next
    Ebook Download
    View all
    View all