Closed minaairsupport closed 5 years ago
I was not able to reproduce this with GMail on my Pixel XL 2.
Showed up just fine. Need more information such as device and email client.
James, I update the issue , the Email client is Outlook
Wow... don't tell me outlook requires a special item in the intent. This is really going to be annoying. We probably need to try a few clients.
yea I notice this now , when I change the email client to gmail body appear , when I back to outlook the body disappear again . when I change BodyFormat to PlainText its working in outlook so the issue appear only when you send html body but let's think what special about outlook , may be it block html body ?
It could simply be that they don't support it. PlainText is the default and recommended route to be honest. We can report it to the outlook team. Probably need to document it, but most likely out of our control. Will get in contact with the Outlook team though.
I don't believe either OutLook docent support html body https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.htmlbody I think we missing something I have reviewed the source code and it seems working nice I make some tries may be we could fix the issue
@minaairsupport Have you tried not only using a text element tag but to include your
and their corresponding end tags? In the outlook documentation they have this in their sample code. When I tried setting outlook up it crashed and launched some settings on Android so I could not reproduce this :(I don't get this sorry , I think the only place I can send my E-mail body is Body property in EmailMessage did you advise me to do something else ?
Thanks Redth for take care of my issue This may be help I think we need to tell the E-mail client what type of body so it may be good idea to add this Intent.ExtraHtmlText
if (!string.IsNullOrEmpty(message?.Body))
{
if (message?.BodyFormat == EmailBodyFormat.Html)
{
ISpanned html;
if (Platform.HasApiLevel(BuildVersionCodes.N))
{
html = Html.FromHtml(message.Body, FromHtmlOptions.ModeLegacy);
}
else
{
#pragma warning disable CS0618 // Type or member is obsolete
html = Html.FromHtml(message.Body);
#pragma warning restore CS0618 // Type or member is obsolete
}
intent.PutExtra(Intent.ExtraText, html);
intent.PutExtra(Intent.ExtraHtmlText, html); // <= Add this Extra html
}
else
{
intent.PutExtra(Intent.ExtraText, message.Body);
}
}
References https://www.w3.org/Protocols/rfc1341/7_3_Message.html https://stackoverflow.com/questions/15814902/sending-html-mail-if-app-allows https://developer.android.com/reference/android/content/Intent.html#EXTRA_HTML_TEXT https://developer.xamarin.com/api/field/Android.Content.Intent.ExtraHtmlText/
No I did not advise you to do something else. Just include the proper HTML start and end tags as well as a body tag in your E-Mail body. That is the string you pass as body would be something like "<html><body><p>This is a test</p></body></html>"
I tried this as well it dosent work I will be waiting for you solve this issue , I make all possible tries
@jamesmontemagno did you ever hear from the Outlook team if this is something that they should support or not?
So, this is out of our control and not supported by the outlook application. Nothing we can really do about it to be honest. Just need to document this correctly.
Could you at least address outlook team to be notified and I will still looking for solution
I have already notified them and they are looking into adding support for it.
walk-around to fix the issue till they support it convert this HTML to plain text
https://gist.github.com/minaairsupport/b14b3aeb59e64ebf41dcf5a0af0fe161
hit the same issue couple of days. Samsung s7 edge with oreo.
if trying to send email with html body
outlook - no body at all
gmail - stripped some tags . for instance - < table >< t* >
Samsung email - no body at all
after googling on that matter found, that this problem is not realted to xamarin essentials but to email clients and even in concrete mail client may vary from version to version. in my opinion it worth to put this in documentation, that html bodies handling by clients may vary from completely ignoring html emails to striping various html tags . at least it will save some time ;)
I agree at least to be documented and my walk around could help as well its the same effect like Gmail
Yes, I am adding: Not all email clients for Android support Html
, since there is no way to detect this we recommend using PlainText
when sending emails.
Late to this party but … I would like to use this package but really need a nice HTML e-mail to result, and on Android even Gmail is not really working with HTML with this package. on IOS it seems good, at least for Gmail.
A trivial sample with a bit of color and bold: mail.Body = "<body
Hi this is Mike! <span style=\"color: #ff0000;\"> In Red! Bold...
";mail.BodyFormat = EmailBodyFormat.Html;
Sends the e-mail and looks like "Hi this is Mike! In Red! Bold...". No red or bold but close! My rather more complex real HTML comes out as gibberish.
Note that when I use System.Net.Mail.SmtpClient the HTML is always rendered correctly at the destination e-mail client. There I use an alternate view -
// Create HTML view AlternateView HTMLEmail = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
// add image to html version of email HTMLEmail.LinkedResources.Add(logo); mail.AlternateViews.Add(HTMLEmail);
Of course this is quite different approach. Any help will surely be appreciated! And jamesmontemagno, I am using many of your fine packages successfully, and you have been a real asset to the community!
Mike
Bug report best practices: Submitting Issues
Description
I tried to send Email with your library , it was nice in iOS but in android I have missing body that happen incase body html
Steps to Reproduce
in iOS you will find Email with body , Android Empty Body
Expected Behavior
Html body
Actual Behavior
Empty body
Basic Information
Screenshots
Reproduction Link