Send Email Task in Windows Phone 8.1

In this post I will show you how to compose and sent an email from you Windows Phone 8.1 app. If you are developing a Windows Phone 8 Silverlight application then you could refer to our other post.
Launchers and choosers – Email Tasks in Windows phone app

The APIs have changed for WinRT applications. Here’s the code that can be used to send email using a Windows Phone 8.1 WinRT application.

// Define Recipient
EmailRecipient sendTo = new EmailRecipient()
{
    Address = "maskaravivek@gmail.com"
};

// Create email object
EmailMessage mail = new EmailMessage();
mail.Subject = "Hello world";
mail.Body = "Email Body";

mail.To.Add(sendTo);
// Open the share contract with Mail only:
await EmailManager.ShowComposeNewEmailAsync(mail);

We are using an EmailRecipient object that contains the email address of the person to whom we wish to send an email. Then we create an object of EmailMessage class and set its Subject and Body. Also we add the all the recipients to the To list. Finally we call ShowComposeNewEmailAsync asyncronously to launch the email app.

How to save ringtone in Windows phone using SaveRingtone Task

This is the sixth blog post of this series in which I am going to tell you about how to save a media file as ringtone of your Windows phone using SaveRingtone Task.
This task launches the Ringtones application, where the user saves the ringtone and can optionally set it as their default ringtone. Once the audio file is added to the list, the user can set it as the ringtone for individual contacts in the Contacts application.

Ringtone audio files must meet the following requirements.

  • Files must be of type M4R, MP3, or WMA.
  • Files must be less than 30 MB in size.
  • Files must not have digital rights management (DRM) protection.

 

Follow the steps given below

1. First create a new project Ringtonetask.

 


 

2. Before going further add the following namespace in the MainPage.xaml.cs. This namespace is required for email tasks in windows phone app.

  3. Create a button on the MainPage and add the following code given below in the click event handler of the button to launch a SaveRingtoneTask.  

The task has got different properties the important one is the source which defines the path of music file in the application.


Note:
Use appdata: for audio files that are part of the application project. They are bundled into the XAP file and stored in the installation directory of the application. Use isostore: for audio files that are stored in isolated storage.

 

The event handler which we need to concentrate now is the Ringtone_Save_completed event handler.

Just below the code of button click event handler add the following code of Ringtone_Save_completed event handler which gives a confirmation message to user.

4. Now just launch the application and click on the save button.

 


 

5. You will see the following message on your screen.

 


 

6. If you have any doubts related to this post you can download the full source project file from the link given below.

Download Full source project file Ringtonetask.zip

How to use ShareStatus Task and ShareLink Task in Windows phone app

This is the sixth blog post of this series in which I am going to talk about ShareStatus task and ShareLink task in Windows phone app.

 

1. First create a new project having the name Statustask.

 


 

2. Before going further add the following Namespace required for the above tasks in the MainPage.xaml.cs.

 

 

ShareStatus Task

It launches a dialog that enables the user to share a status message on the social networks (Facebook, Windows Live, etc.).

To use it you need to create a new instance of this task, set the status property and the launch the task.

In the following project I have created a new button on the MainPage.xaml to launch the task. The code for click event handler of button is given below.

 

 


 

ShareLink Task

It launches a dialog that enables the user to share a link on the social networks like for example Facebook, Windows Live, etc.

To use it you need to create a new instance of this task, set the desired properties as given below and then launch the task.

In the following project I have created a new button on the MainPage.xaml to launch the task. The code for click event handler of button is given below.

 

 


 

I hope this post will be helpful to you. You can download the full project source file from the link given below.

 
Download full project file Statustask.zip
 

Web browser Task in and Windows Phone 8.1 and 8.0 app

This is the fifth blog post of this series in which I am going to talk about Search tasks in Windows phone app.

In this post I shall be discussing about WebBrowserTask.

 

1. First create a new project having the name SearchTasks.

 


 

2. Before going further add the following Namespace required for the above tasks in the MainPage.xaml.cs.


 

WebBrowser Task

With the help of this task you can launch the phone’s default web browser on a given URL. All you need to do in order to implement this functionality is just to create an instance of WebBrowsrTask, set the URL field and then call Show().

In the following project I have created a new button on the MainPage.xaml to launch the task. The code for click event handler of button is given below.

Windows Phone 8

Windows Phone 8.1

Windows Phone 8.1 uses a Launcher class to

 

I hope this post will be helpful to you. You can download the full project source file from the link given below.

Download full Project file WebBrowserTask.zip

Launchers and choosers – Marketplace Tasks in Windows phone app

This is the fourth blog post of this series in which I am going to talk about different Marketplace tasks in Windows phone app.

In this post I shall be discussing about four different tasks

1. MarketplaceReviewTask

2. MarketplaceDetailTask

3. MarketplaceHubTask

4. MarketplaceSearchTask

 

1. First create a new project having the name Marketplacetasks.

 


 

2. Before going further add the following Namespace required for the above tasks in the MainPage.xaml.cs.

  MarketPlaceReview Task It is a quiet useful task and is of great importance. It launches the Windows Phone Marketplace client application which then displays the review page for your application. Create a button on the MainPage to launch the task. When we will click on this button it will take us to the review page of the application. The code for click event handler of this button is given below.  

 

MarketPlaceDetail Task

It launches the Windows Phone Marketplace client application and shows the details page for a product specified by the unique identifier you provide. Content identifier is the product ID from the manifest. You can set another external ID or if left empty, then it should use the current app product ID.

The default ContentType is ContentType.Applications so there is no need to change it if you’re bringing up your Application details page.

Suppose I want to add the link of my other application in my current app. I will set the content identifier to the product Id of the application which I want to add.

For example – Create a button on the MainPage to launch the task. Set the content identifier as specified. When we will click on the button it will open the Marketplace page of the application.

The code for click event handler of this button is given below.

    MarketPlaceSearch Task It launches the Windows Phone Marketplace client application which then shows the search results based on search terms you provide. Note that you can search by SearchTerms(keyword) and ContentType. For example I want to search for a specific app having the name Tilemaker I will set the search term to Tilemaker. Create a button on the MainPage to launch the task. The code for click event handler of this button is given below.  

 

MarketPlaceHub Task

It launches the Windows Phone Marketplace client application. Set the ContentType property to a value from the MarketplaceContentType enumeration in order to launch the hub to a particular type of content:

MarketplaceContentType.Music – music content

MarketplaceContentType.Applications – application content

To demonstrate it we shall create a button on the MainPage. When we will click on it the marketplace will get open on the phone.

The code for click event handler of this button is given below.



 

I hope this post will be helpful to you. You can download the full project source file from the link given below.

Download Full Project file MarketplaceTasks.zip

Launchers and choosers – Phone number tasks in Windows phone app

This is the third blog post of this series in which I am going to talk about different Phone number tasks in Windows phone app.

In this post I shall be discussing about five different tasks

1. SavePhoneNumberTask

2. PhoneNumberChooserTask

3. PhoneCallTask

4. SmsComposeTaks

5. SaveContactTask

 

1. First create a new Project having the name Phonenumbertasks.

 


 

2. Before going further add the following Namespace required for the above tasks.

 

 

SavePhoneNumber Task

It launches the contacts application and saves the provided phone number to the Contacts list. This is done by calling

the Show method of the SavePhoneNumberTask object. You can obtain the result of the chooser operation by handling the Completed event.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 

The code for Task completed event Handlers is as follows.

 

 


 

Phonecall Task

Making a phone call is just so easy with the PhoneCallTask .It launches a Phone app that will enable users to make a phone call from your application.

Create a button on the MainPage to launch the task. The code for the click event handler of this button is given below.

 

 

Note: Whenever using PhoneCallTask remember to add the Following Capabilities in WmAppManifest.xml.

The capability required for phone call is ID_CAP_PHONEDIALER.

Otherwise it will give an Exception.

 


 


 

SmsComposeTask

Composing and sending sms can be done with the SmsComposeTask which launches the Messaging application which displays a new sms message. It expects a phone number which could be provided just as a string, but in-real world application user expect to select it from his contacts and if not found enter manually.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 


 

PhoneNumberChooser Task

PhoneNumberChooserTask launches the Contacts application and allows the user to select a contact’s phone number. If the contact has multiple phone numbers, you have to select one of the them.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 

The code for Task completed event Handlers is as follows.

 

 

SaveContact Task

You can easily save a new contact on your phone with the help of SavecontactTask. It has got different properties which can be left null. But the essential ones are described below.

Create a button on the MainPage to launch the task. The code for the click event handler of this button is given below.

 

 



 
I hope this post will be helpful to you. You can download the full project source file from the link given below.

 
Dowload full project file Phonenumbertasks.zip
 

Launchers and choosers – Email Tasks in Windows phone app

This is the second blog post of this series in which I am going to tell you about different Email tasks in windows phone application.

In this post I shall be discussing about three different tasks which are

 1. SaveEmailAddressTask

2. EmailAddressChooserTask

3. EmailComposeTask

 

1. First of all create a new Project having the name Emailtask.

 


 

2. Before going further add the following namespace in the MainPage.xaml.cs.This namespace is required for email tasks in windows phone app.

 

 

3. If you want to save an email address you can use the SaveEmailAddressTask in windows phone.

 

SaveEmailAdress Task

It allows your application to launch the Contacts application and enables users to save a new email address to the Contact lsit. This is done by calling the Show() method of the SaveEmailAddressTask  object. You can obtain the result of the chooser operation by handling the Completed event.

Create a button on the MainPage to launch the task and check its result in task completed event handler. The code for the click event handler of this button is given below.

 

 

The code for Task completed event Handlers is as follows.

 

 

EmailComposeTask

This launcher (EmailComposeTask) allows you to send email from your application by launching the Email application which displays a new email message.

Create a button on the MainPage to launch this task. The code for the click event handler of this button is given below.

 

 

It has got different properties which are self-understood.

 

EmailAddressChooserTask

Choosing email address from the existing ones can be just so easily implemented through the EmailAddressChooserTask. It launches the phone contacts application and allows the user to select particular email address.

Create a button on the MainPage to launch this task. The code for the click event handler of this button is given below.

 

 

The code for the Task completed event Handlers is given below. The email address to which email has to be sent has been changed to that selected from the contact list.

 

 


 

4. I hope this post will be helpful to you. You can download the full project source file from the link given below.

 
Download Full Project Source file EmailTaks.zip
 

How to choose photo from media library or capture a new one in windows phone app

This is the first blog post of this series in which I am going to tell you about how to choose a image from the phone media gallery and How to capture a new image and display it.

The task that we shall be using is PhotoChooserTask. We shall be using the task complete event handler for this purpose.

 

Different steps involved are

 

1. Create a new project called Photochooser.

 


 

2. Firstly I shall demonstrate you how to choose the image from the existing ones that are there in media library of your phone

 

The namespace required for Launchers and Choosers task is

 

 

Select the existing image

Create a button on the MainPage and add the following code given below in the click event handler of the button to launch a Photochooser task.

 

 

The task has got different properties the important ones are the height and width of the image which we want to select.

The event handler which we need to concentrate on is the Photoresult event handler.

Just below the code of button click event handler add the following code of PhotoResult event handler.

 

 

The code given above will set the image source of image control to that of the image chosen from the media library.

 

3. We can also capture a new image by launching CameraCapturetask

.

Capturing image from camera

Create a new button on the MainPage and add the following code for launching the CameraCapturetask in the click event handler of button.

 

 

This task has got no properties. The event handler which we need to concentrate on is same as that of Photochooser which is PhotoResult.

Just below the code of button click event handler add the following code of PhotoResult event handler.

 

 

The code above will set the image source of image control to that of image you have captures from your camera.

 


 

4. If you have any doubts related to this post you can download the full source project file from the link given below.

 
Download full Project Source file Photochooser.zip
 

5. If you want to save the selected or captured image to isolated storage you can refer to the link of following post given below.