Android, How to send HTML email and force Android to send it through G-Mail not other applications? -


I want to send an email through my application. I need to send HTML based email through G-Mail. I have got the following solutions, each of which is professional and cons.

1) Use of intent (Intent.ACTION_SEND) This is a very easy way and I can see my body in HTML format, but the problem is that when I click the "Send Email" button , So many applications such as Facebook and Google+ pop ups that are useless and should not be shown to me in that list. This is his code:

  string html = "& lt;! DOCTYPE html> 

body & gt;

Enter image details here  Enter image details here

2) Use of intent (Intent.ACTION_SENDTO). This way the filter shows useless applications and only shows the mail client but it does not display my email in the Gmail client in the HTML client. When I send an email, some clients show body in HTML format while others do not recognize HTML and my link behaves like plain text. This code is as follows:

  string html = "  body> gt; & lt; a href = \" http: / /www.w3schools.com \ "target = \" _ blank \ "& gt; Go to W3Schools.com! & Lt; / a & gt;" + "& Lt; p & gt; If you set the target attribute to \" _ blank \ ", the link will open in a new browser window / tab. & Lt; / p & gt; & lt; / body & Gt; & lt; / html & gt; "; Send Intent = New Intent (Intent.ACTION_SENDTO); String uriText = "mailto: my email address" + "? Subject = subject here" + "and body =" + html; UriText = uriText.replace ("", "% 20"); Uri Uri = Uriper's (Yuri Text); Send.setData (URI); StartActivity (Intent.createChooser (Send, "Send Mail ..."));   

Enter image details here  Enter the image details here

3) Using the mail, the application adds so much complexity and I have not tested it yet Done

What is your suggestion? I want a method for the benefits of first and second methods. I need to click on the user's button, it shows Gmail to the customer and I can show him / her html content in the body of the client.

Any suggestion would be appreciated. Thanks

======================

Update < P> The code is something wrong about Code 2:
  string html = "  gt; body & gt; ; & Lt; a href = \ "http://www.w3schools.com \" Target = \ "_ blank \" & gt; Go to W3Schools.com! & Lt; / a & gt; + "& Lt; p & gt; If you set the target attribute to \" _ blank \ ", the link will open in a new browser window / tab. & Lt; / p & gt; & lt; / body & Gt; & lt; / html & gt; "; Send Intent = New Intent (Intent.ACTION_SENDTO); String uriText = "mailto: my email address" + "? Subject = subject here" + "and body =" + + HTML Html HTML (html); UriText = uriText.replace ("", "% 20"); Uri Uri = Uriper's (Yuri Text); Send.setData (URI); StartActivity (Intent.createChooser (Send, "Send Mail ..."));   

Enter image details here

Try the following -

  intro shareIntent = new intent (Intent.ACTION_SENDTO, Uri.parse ("mailto : ")); ShareIntent.putExtra (Intent.EXTRA_TEXT, Html.fromHtml (body)); ShareIntent.putExtra (Intent.EXTRA_SUBJECT, topic); StartActivity (shareIntent);   

This will only present email applications.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -