DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Playing with the Email Compose Task in Windows Phone

Playing with the Email Compose Task in Windows Phone

Karthikeyan Anbarasan user avatar by
Karthikeyan Anbarasan
·
Apr. 25, 12 · Mobile Zone · Interview
Like (0)
Save
Tweet
4.22K Views

Join the DZone community and get the full member experience.

Join For Free

In this how-to tutorial we are going to see an important and useful task for composing an email using the Launchers that are available as part of Windows Phone. To get some clear idea on Launchers and for a list of Launchers check this article on Working with Launchers in WP7. The Email Compose Task allows the application to launch the email application and opts to enter a new mail message. We can play around with providing the different options like having the recipients name, Email id, subject, to, cc, bcc etc. Once we are done with the required options the email will be sent once the send button has been clicked, which will be available as part of the Email application. Let us see the different code on how to make use of the Email Compose Task in Windows Phone development.

Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the Email Compose task.

2012-03-27 07h25_23

Now let us make some changes to the UI, which on button clicks will launch the Email Message application. We are going to add a button which will trigger the email compose task. Once we added the button in the code behind we need to start with the code. The Email Compose task has the assembly Microsoft.Phone.Task as the namespace, which is needed to be added in the using statement as below code

using Microsoft.Phone.Tasks;

Microsoft.Phone.Task.EmailComposeTask has the below set of properties which are used to play around with the email message sending application which basically creates a new Email Message and sends it to different recipients.

Properties:



Now in the button click event we need to play around with the code as shown below.

Code:

using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugWp7EmailComposeTask
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            EmailComposeTask f5EmailCompose = new EmailComposeTask();
           
            f5EmailCompose.To = “Karthikeyan@f5debug.net”;
            f5EmailCompose.Subject = “F5Debug Tutorial”;
            f5EmailCompose.Body = “EMail Compose Task Sample Application”;
            f5EmailCompose.Show();

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            EmailComposeTask f5EmailCompose = new EmailComposeTask();

            f5EmailCompose.To = “Karthikeyan@f5debug.net”;
            f5EmailCompose.Subject = “F5Debug Tutorial”;
            f5EmailCompose.Body = “EMail Compose Task Sample Application”;
            f5EmailCompose.Cc = “KarthikCC@f5debug.net”;
            f5EmailCompose.Show();

        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            EmailComposeTask f5EmailCompose = new EmailComposeTask();

            f5EmailCompose.To = “Karthikeyan@f5debug.net”;
            f5EmailCompose.Subject = “F5Debug Tutorial”;
            f5EmailCompose.Body = “EMail Compose Task Sample Application”;
            f5EmailCompose.Bcc = “KarthikBCC@f5debug.net”;
            f5EmailCompose.Show();

        }
    }
}

Now we are done with our code, just run the application and we can see the expected output as shown below. Basically we will not have the option to test with the emulator as the emulator will prompt you to set the internet to send the message. So we can set up the account and then try to use the code which will send the mail accordingly.

Output:

image

 

Windows Phone Task (computing)

Published at DZone with permission of Karthikeyan Anbarasan, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The Evolution of Configuration Management: IaC vs. GitOps
  • How To Integrate Third-Party Login Systems in Your Web App Using OAuth 2.0
  • Evolving Domain-Specific Languages
  • 6 Things Startups Can Do to Avoid Tech Debt

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo