top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to configure a Email in Windows Phone 8 Application?

+1 vote
76 views

I need complete code for sending mail(compose mail) from my windows phone application any one help how to achieve this........

posted Nov 6, 2014 by Sathish Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

Check This how to send email through Windows Phone 8 application??

In visual studio 2012
1. Create new Xaml file Name MainPage.Xaml
2. Paste the following

XAML CODE:

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

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
        <TextBlock Text="page name" 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">
          <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button Grid.Row="0" x:Name="btnSaveEmailAddress" Content="Save Email Address"     
        Click="btnSaveAddress_Click" />
        <Button Grid.Row="1" x:Name="btnChooseEmailAddress" Content="Choose Email Address" Click="btnChooseEmailAddress_Click"/>
        <Button Grid.Row="2" x:Name="btnComposeEmail" Content="Compose Email" Click="btnComposeMail_Click"  />
    </Grid>
 </Grid>
  1. Right Click MainPage.Xaml and select View Code in that MainPage.Xaml.cs Paste the following codes:

     using System;
     using System.Collections.Generic;
     using System.Linq;
     using System.Net;
     using System.Windows;
     using System.Windows.Controls;
     using System.Windows.Navigation;
     using Microsoft.Phone.Controls;
     using Microsoft.Phone.Shell;
     using WP8EmailTasksDemo.Resources;
     using Microsoft.Phone.Tasks;
    
      namespace WP8EmailTasksDemo
      {
       public partial class MainPage : PhoneApplicationPage
        {
         SaveEmailAddressTask saveEmailAddressTask;
           EmailAddressChooserTask emailAddressChooserTask;
    
    // Constructor
    public MainPage()
    {
        InitializeComponent();
    
        this.emailAddressChooserTask = new EmailAddressChooserTask();
        this.emailAddressChooserTask.Completed += new EventHandler<EmailResult>(emailAddressChooserTask_Completed);
    
        this.saveEmailAddressTask = new SaveEmailAddressTask();
        this.saveEmailAddressTask.Completed += new EventHandler<TaskEventArgs>(saveEmailAddressTask_Completed);
    
    }
    
    private void btnSaveAddress_Click(object sender, RoutedEventArgs e)
    {
        saveEmailAddressTask.Email = "testmail@test.com";
        saveEmailAddressTask.Show();
    }
    
    private void saveEmailAddressTask_Completed(object sender, TaskEventArgs e)
    {
        if (e.TaskResult == TaskResult.OK)
        {
            MessageBox.Show("Email successfully Saved..");
        }
    }
    
    private void btnChooseEmailAddress_Click(object sender, RoutedEventArgs e)
    {
        emailAddressChooserTask.Show();
    }
    
    private void emailAddressChooserTask_Completed(object sender, EmailResult e)
    {
        if (e.TaskResult == TaskResult.OK)
        {
            MessageBox.Show("Selected email :" + e.Email);
          }
    }
    
    private void btnComposeMail_Click(object sender, RoutedEventArgs e)
    {
        EmailComposeTask emailComposeTask = new EmailComposeTask();
        emailComposeTask.To = "chris@example.com";
        emailComposeTask.To = saveEmailAddressTask.Email;
        emailComposeTask.Body = "WP8 Emails Demo";
        emailComposeTask.Cc = "testmail2@test.com";
        emailComposeTask.Subject = "Windows Phone 8";
        emailComposeTask.Show();
          }
       }
    }
    

enjoy the code.......

answer Nov 11, 2014 by Jdk
Similar Questions
+1 vote

I am using Visual Studio 2013 for developing windows phone application how to test my application any one explain how can i achieve this... thanks in advance:)

+2 votes

I need XAP File for put my own application in my windows phone local store but i dont know where the XAP file placed in my application...........

+1 vote

I need to know how to achieve the following thigs??
1. Passing a string value using formatted string.
2. Passing multiple parameters.
3. Passing complex object

+8 votes

I am using VS 2012 and install emulator 8. Now i need some sample application code for developing my first app in windows phone 8.

+1 vote

How to use windows phone default date picker control......

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...