Floating FB popout byF5debug

Steps to Send Emails from Windows Store app for Developers

In this article we are going to see how to send emails from Windows Store application step by step. Sending email from the application is one common feature that is required in most of the cases by the developers to send some information to the customer on periodic basis or on demand as and when required. Windows Store app has no inbuilt module which can hold the framework to send emails on demand, we can use a third party component called “LimiLabs IMAP Component for .Net” which does the same process that is required to send emails from Windows Store apps which has a free version and a paid version. You can download the package directly using this link http://www.limilabs.com/mail/thank-you?url=mail%2FMail.zip

Once you download the package, follow the below steps to use this component and send emails from Windows Store application.

Step 1 – Open Visual Studio 2013 and and create a new Windows Store Project using C# and Xaml  or open your existing application from which you want to send emails using this component.

Step 2 – Add the reference to the dll which we downloaded from the link by Clicking on Add reference in Visual Studio and pointing the appropriate dll file (MailForWindowsStore.dll).

image

Step 3 – Add the below namespaces to the code behind, which are basically required to build the application. These namespaces are for the component which we are using to build the email procedure and send across. In this example on a button click we will write the code which can be used in any layer at any part of the code.

using Limilabs.Client.SMTP;
using Limilabs.Mail;
using Limilabs.Mail.Headers;

Step 4 - Now in the button click event lets write a sample code which is basically we hard code the content, body, subject, to and from email ids etc. In real time you can get user specific information and assign to the specific fields before sending the email to the customer.

private async void Button_Click(object sender, RoutedEventArgs e)
        {
            MailBuilder mbBase = new MailBuilder();
            mbBase.Html = "This is the Body Content";
            mbBase.Subject = "This is the Subject Content";
            mbBase.To.Add(new MailBox("Karthikeyan@f5debug.net"));
            mbBase.From.Add(new MailBox("Karthik@f5debug.net"));

            IMail iemail = mbBase.Create();

            using (Smtp smtpBase = new Smtp())
            {
                await smtpBase.Connect("smtp.gmail.com", 587);
                await smtpBase.UseBestLoginAsync("Karthikeyan@gmail.com", "Password123");
                await smtpBase.SendMessageAsync(iemail);
                await smtpBase.CloseAsync();
                MessageDialog Mymsg = new MessageDialog("Mail sent!!");
                Mymsg.ShowAsync();
            }
        }

 

image

 

 

 

 

 

 

 

 

 

 

 

 

 

Now we are done with the code, in the above code MailBuilder class is the 3rd party component class which is used to get the collective information that is required to send the email. IMail class is to create the instance to push the email to the customer and SMTP class to set the email with the base credentials.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter