Xamarin Utility in 5 Minutes with Plugins

[This article was restored]

I needed a quick and dirty program to create quick notes and mail them to myself.  You can see how this would be useful;  a way to jot down notes while away from the computer, with some high likelihood that I’ll see and remember the note when I get back.

I created a Xamarin.Forms application, and dropped an editor onto the page.  Here’s the complete XAML page:

  <?xmlversion="1.0"encoding="utf-8"?>
 <ContentPage
 xmlns="http://xamarin.com/schemas/2014/forms"
 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
 xmlns:local="clr-namespace:TextToMe"
 x:Class="TextToMe.TextToMePage">
 <StackLayout
 Padding="30">
   <Editor
   HeightRequest="300"
   x:Name="MessageEditor"
   Completed="Handle_Completed"
   BackgroundColor="Yellow"/>
 </StackLayout>
 </ContentPage> 


I implemented the event handler in code behind (this project was too small for MVVM),

  voidHandle_Completed(objectsender, System.EventArgse)
 {
   string message;
   message=MessageEditor.Text;
   varemailTask=MessagingPlugin.EmailMessenger;
   if(emailTask.CanSendEmail){
     emailTask.SendEmail("jesseliberty@gmail.com","Texttome",message);
     MessageEditor.Text="";
   }
 }
 

The magic here is accomplished by the Messaging plugin, which will let you make a phone call, send an SMS message or, in this case, send an email.  I could use some of the advanced features, like adding an attachment, but don’t need to.  I just want to send my text.  The three parameters are:

  • Recipient email address
  • Subject line
  • Body of message

 Pierce Boggan wrote up how to use the plugin in an excellent Xamarin blog article.

Hey! Presto! instant app.  But, the simulator can’t send email, so if you want to try it out, you need to do so on a device, which means you need to provision your phone.  Don’t panic, step by step directions are provided here.

Complete development time: 4 minutes.

 

But as I say, it is quick and dirty.  If I want to put it in the store, I still have some work to do.  First, I really don’t want all your notes, so I need an easy setup so that you can enter your own email address.  Second, it is ugly. Third, I need images, lots of images for the app store.  If you want to take that on, let me know and we can share the glory (and who knows, maybe advertising revenue).
Share

About Jesse Liberty

Jesse Liberty is an independent consultant and programmer with three decades of experience writing and delivering software projects. He is the author of 2 dozen books and multiple Pluralsight courses, and has been a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP, Microsoft MVP and Telerik MVP.
This entry was posted in Xamarin. Bookmark the permalink.

Leave a Reply

Your email address will not be published.