SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Vista, etc.







How to Send Email using EmailComposeTask in Windows Phone 8 App

Windows Phone 8 app developers use EmailComposeTask to send email within a Windows Phone 8 app. EmailComposeTask (email compose task) is a Windows Phone 8 Launcher which launches email application on WP8 users smartphone with set values of email fields within app code. Programmers can build their app code so that the email subject, body and the recipients of the email can be configured and displayed as a new email message when the Windows Phone user taps a button on the app page.

Of course for the sake of the Windows Phone user's security, the configured email message can only be sent if the user presses the send button in the email app.

EmailComposeTask

EmailComposeTask is one of Windows Phone Launchers that is available on Windows Phone 8 and Windows Phone 7.1 In order to use EmailComposeTask just like any other launchers (WebBrowserTask, SmsComposeTask, ShareLinkTask etc.) the Microsoft.Phone.Tasks namespace should be included within the app code. So if the Windows Phone 8 app developer is using VB.NET then add Microsoft.Phone.Tasks namespace as follows:

Imports Microsoft.Phone.Tasks

If the Windows Phone app is being developed using C-Sharp (C#) than use the "Using" syntax

using Microsoft.Phone.Tasks;

Now developers are ready to add a button to demonstrate how to send an email within a WP8 app. Place a button or an eMail image like I did on my free Windows Phone 8 Time Management Quotes app on one of the app pages, let's say on design view of MainPage.xaml

send email from Windows Phone 8 app using EmailComposeTask Launcher
Send email from Windows Phone 8 app using EmailComposeTask Launcher

Now switch to Events tab of the Properties screen of the button or image component and create a Tap event. Since I named as "email" the picture I used in design view, the Tap event is automatically named as email_Tap Let's now switch to code behind MainPage.xaml.vb of the app page MainPage.xaml

The Tap event code actually makes call to a method named sendEmail which creates an instance of the EmailComposeTask. When the EmailComposeTask instance is created, the Subject property and Body property of the email compose task is populated with application values. These are the text values displayed on screen to the Windows Phone 8 app user.

Private Sub email_Tap(sender As Object, e As GestureEventArgs) Handles email.Tap

 Dim selectedQuote As Quote = TimeTrackingQuotes.Read(currentQuoteNo)
 If Not selectedQuote Is Nothing Then
  sendEmail(selectedQuote)
 End If

End Sub

Private Sub sendEmail(quote As Quote)

 Dim emailComposeTask As EmailComposeTask = New EmailComposeTask()

 emailComposeTask.Subject = quote.QuoteTitle
 emailComposeTask.Body = quote.QuoteText

 'emailComposeTask.To = "recipient@kodyaz.com"
 'emailComposeTask.Cc = "cc@kodyaz.com"
 'emailComposeTask.Bcc = "bcc@kodyaz.com"

 emailComposeTask.Show()

End Sub

Please note that I did not set TO, CC or BCC properties of the EmailComposeTask. But you can configure these values within the Windows Phone app codes.

EmailComposeTask Show() method launches default email app on the Windows Phone device with configured field values just like in below screenshot.

send email from Windows Phone 8 app using EmailComposeTask Launcher  EmailComposeTask email compose task Windows Phone Launcher  compose and send email from Windows Phone app
Compose and send email from Windows Phone 8 app using EmailComposeTask Launcher

Since the EmailComposeTask Windows Phone launcher is using the Windows Phone user's defined active email accounts, the user must have already set up an email account on the Windows Phone 8 device.

set up an email account
Can't send
Make sure you've set up an account and try again.

An other place where programmers can use send email function in Windows Phone 8 apps is send feedback pages. Windows Phone app developers can add a app review button or send feedback button with TO field is set to their email addresses and subject field is set to the name of the current Windows Phone 8 app. When the EmailComposeTask displays the email app, users can type their feedback or review in the Body field and send the email to the app developers or app publishers.





Windows Phone 8

WP8 App Development

Windows Phone SDK

Register Phone

WP8 App Download Count

Windows Phone App

Windows Phone Launchers

WP8 Accent Colors

LaunchUriAsync URI Scheme

WP8 Kid's Corner

WP8 Features

Nokia Lumia 920





Windows 8

Windows 8 Tutorials

Windows 8 Download

Install Windows 8

Windows 8 Product Key

Windows 8 Tips

Windows 8 Games


Windows 8 tablet

Microsoft Surface

Samsung Slate 7

Asus Taichi


Windows 8 Phones

Nokia Lumia 920

Windows Phone 8 App Development

Register Phone

Windows Phone 8 Features








Microsoft Windows 8 Downloads, tutorials, guides and how-to documents

Microsoft Windows 8 Download
How to Create Flip Tile Programmatically in Windows Phone 8 App
How to Create Cycle Tile Programmatically in Windows Phone 8 App
New Windows Phone 8 Features
Download Windows Phone SDK 8 for Visual Studio 2012 and Windows Phone Emulator
Add Search Providers like Google Search Provider to Internet Explorer 10 IE10
Enable and Configure Kid's Corner on Windows Phone 8 Smartphones
How to Change Windows Phone 8 Broadcast Name
How to Change Windows Phone 8 Device Name
Download Windows Phone App for Windows 8
Windows Phone 8 App Development: A Quick Start Guide
Search for an App on Windows 8 App Store
Reinstall App Store for whom Removed Windows App Store
Create Picture Password for Windows 8 User
Windows 8 Tips - Windows 8 Close App
Group and Name Windows 8 Tiles on Start Screen
Learning Windows 8 Diary - What I learnt today
Windows 8 Installation Stuck at Getting Devices Ready
Rate Windows 8 Performance using Windows Experience Index
Windows 8 File Explorer aka Windows 8 Explorer
Pin Program to Taskbar using Windows 8 Pin to Taskbar option
How to Change Windows 8 Language
Windows 8 Wallpapers
How to Shutdown Windows 8
Windows 8 App Development using Visual Studio 11 Express
Windows 8 Installation (Windows Consumer Preview)
Install Windows 8 on Virtual Machine Oracle Virtual Box Configuration
Windows 8 Screenshots from Windows Consumer Preview Beta
Windows 8 Product Key to for Windows Consumer Preview Setup
Windows 8 Installation Compatibility Advisor Report
Tweet@rama Windows 8 Application for Twitter
Microsoft Windows 8 Activation using Desktop Control Panel
Windows 8 Product Key to Reinstall Windows 8
Change Screen Resolution in Windows 8 for Metro-Style Applications
How to Install Windows 8 - Installation Screenshots
New Windows Task Manager in Windows 8
Windows 8 Startup Repair with System Restore
How to Change Windows 8 User Account Picture
Windows 8 Tips and Tricks
Windows 8 Setup Error: HAL_INITIALIZATION FAILED. Your PC ran into a problem that it couldn’t handle, and now it needs to restart.
Windows 8 Games
Windows 8 with Windows 8 Xtreme






Copyright © 2004 - 2014 Eralper Yilmaz. All rights reserved.
Community Server by Telligent Systems