Introduction



Home Screen :

Name of Experiment : Do your Emails

Exp No : MC7

Background : Student should have a basic knowledge of C#.

Summary : Sending an email is an in-built functionality of the mobile device. But, sometimes we require this activity through your own app. Using this experiment you will get to know, how to add this functionality in your current Mobile development.

Learning Objective : To learn the activity of sending Email through this experiment.

Target

Target Platform : This experiment is tested on Windows Phone Emulator and Nokia Lumia 800.

Procedure

SourceCode

Source Code : Comments :
MainPage.xaml
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ExperimentTitle" Text="ExpNo MC7" TextAlignment="Right" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="ApplicationTitle" Text="Mobile Computing" Style="{StaticResource PhoneTextNormalStyle}"/>

<TextBlock x:Name="PageTitle" Text="Email Chooser" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Content="Send Email" Height="72" Name="button1" Margin="6,170,6,338" Click="button1_Click" />
</Grid>
</Grid>











 Exp No MC7(Experiment title)

 Mobile Computing(Application title)


 Email Chooser(Page title)


MainPage.xaml.cs
using System;
using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace EmailTask
{
public partial class MainPage : PhoneApplicationPage
{
EmailAddressChooserTask _emailchooser;
EmailComposeTask email;
// Constructor
public MainPage()
{
InitializeComponent();
_emailchooser = new EmailAddressChooserTask();
_emailchooser.Completed+=new EventHandler<EmailResult>
(_emailchooser_Completed);

}
private void _emailchooser_Completed(object sender, EmailResult e) {
if (e.TaskResult == TaskResult.OK) {
email = new EmailComposeTask();
email.To = e.Email;
email.Show();
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
_emailchooser.Show();
}
}
}




 Add Reference to Microsoft.Phone.Tasks






 Declare the EmailAddressChooserTask and EmailComposeTask


 Initialise EmailAddressChooserTask as _emailchooser




 Instantiate email as EmailComposeTask






 Call _emailchooser.Show() method.

Snapshots





Observation

Observation : It is observed that we can use this experiment in different Mobile App development.

Video Link

For Windows Phone

Download

Right Click Here And Select Save Target For Entire Download :

Do your Email Experiment