How to send Email with HTML formatting to Windows Phone C#

Asked

Viewed 208 times

4

Hello, Visual Studio 2012 has Emailcomposetask Object, but it does not have HTML formatting, I would like to know how to send emails via Windows Phone with HTML Formatting.

  • 2

    According to http://stackoverflow.com/questions/19030764/send-html-content-via-emailcomposetask is invalid. @Natanael-ribeiro-Ferreira But you can try this library: http://www.geekchamp.com/marketplace/components/livemailmessage See also: http://stackoverflow.com/questions/19030764/sendht-ml-content-via-emailcomposetask

  • This library will solve my problem, thank you very much.

  • Please mark as answer. @Natanael-ribeiro-Ferreira

1 answer

2


According to that answer and the description of the property Emailcomposetask.Body on MSDN:

The Body Property does not support HTML formatting.

There’s no way.

However you can use this component (paid): http://geekchamp.com/marketplace/components/livemailmessage

See an alternative solution (on the first link): https://stackoverflow.com/questions/19030764/send-html-content-via-emailcomposetask Here a screenshot of the component that allows including attachment.

Implementation example:

//create a new MailMessage object
MailMessage mailMessage = new MailMessage();
//set a Live/Hotmail or Gmail, or a custom SMTP account
mailMessage.UserName= "*****@hotmail.com ;                        // ****@gmail.com, ****@yourserver.com, etc.
mailMessage.Password = "********";
mailMessage.AccountType = accountType.MicrosoftAccount;   //you can set your  CustomSMTP server/port/no-ssl
mailMessage.From = "[email protected]";
//set mail data
mailMessage.To = "[email protected]";
mailMessage.ReplyTo = "[email protected]";
mailMessage.Cc= "[email protected];[email protected];[email protected]";
mailMessage.Bcc= "[email protected];[email protected];[email protected]";
mailMessage.Subject = "Hello from WP";
mailMessage.Body = "I can send any type of attachment from my app now !!";   **//text or HTML**
//attach ANY KIND of file from a resource or IsolatedStorage path
mailMessage.AddAttachment("\resources\file.jpg"); 
mailMessage.AddAttachment("\docs\file.pdf"); 
mailMessage.AddAttachment("\docs\file.xls");
mailMessage.AddAttachment("\rex\file.wav");
mailMessage.AddAttachment("\myFolder\file.mp3"); 
mailMessage.AddAttachment("\downloads\file.mp4"); 

//attach from in-memory data:
mailMessage.AddAttachment(Encoding.UTF8.GetBytes("yesssss".ToCharArray()), "memoryfile.txt");
//set message event handlers
mailMessage.Error +=  mailMessage_Error; 
mailMessage.MailSent += mailMessage_MailSent; 
mailMessage.Progress += mailMessage_Progress;  
//send email (async)
mailMessage.SendMail();

Sources:
http://www.geekchamp.com/marketplace/components/livemailmessage https://msdn.microsoft.com/library/windows/apps/microsoft.phone.tasks.emailcomposetask.body(v=vs.105). aspx

  • 1

    Hstack, If possible edit the answer and bring more information as to why it is not possible, here in the section Remarks have something on. If it is not too much to ask, post an example of use of the mentioned library or something alternative. Take a look at How do I write a good answer? also. = D

  • 1

    Okay, I’ll update the answer soon. @Qmechanic73

  • 2

    +1. Got better now. = D

  • Thank you @Qmechanic73 :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.