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.
|