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).
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.
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";
IMail iemail = mbBase.Create();
using (Smtp smtpBase = new Smtp())
await smtpBase.Connect("smtp.gmail.com", 587);
await smtpBase.UseBestLoginAsync("Karthikeyan@gmail.com", "Password123");
MessageDialog Mymsg = new MessageDialog("Mail sent!!");
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.