How to send HTML Mail in Android - android

IO want to send email in html format in android. I am able to send mail via gmail client but I am not able to get the styles of html of when I use any other client. I have used below code
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/html");
i.putExtra(Intent.EXTRA_SUBJECT, "TestMail");
i.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml("<p><b>Some Content</b></p>"));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(EmailHtmlActivity.this, "There are no email clients installed.",Toast.LENGTH_SHORT).show();
}

try this I am not sure but it may be help you..
startActivity(Intent.createChooser(new Intent(Intent.ACTION_SEND).setType("message/rfc822")
.putExtra(Intent.EXTRA_SUBJECT, subject)
.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new String().concat("YOUR MESSAGE")),
"Send your email in:"));
Thanks.

Related

Send email from Android App without user's intervention

I would like to send an email to given email address with some default instructions. I know that I can achieve it for sms by using twilio but don't know how to do this via mail..
You can directly use following to send mail with body:
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String\[\]{ "serveroverloadofficial#gmail.com"});
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
intent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");
intent.setType("message/rfc822");
try {
startActivity(Intent.createChooser(intent,
"Send email using..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(),
"No email clients installed.",
Toast.LENGTH_SHORT).show();
}
}
});
Use Mailgun.com to send email by Using their API.

How to send an email in Android without action to UI?

I want to use Intent to send an email without any touching in the screen. I tried the bellow code but it requires to choose many steps: such as email client, send button...I do not want to perform these steps. Just auto send without any touching in the screen. Is it possible in Android M? Thanks
//Email
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"abc#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Title");
i.putExtra(Intent.EXTRA_TEXT , "Body");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
using Intent with ACTION_SEND should open all Apps that can handle sending emails and user will have to select one of them to proceed with sending.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:user_name#provider"));
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT,"Body");
try {
startActivity(Intent.createChooser(intent, "Send Email"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
but if want to send email without using other apps (email clients), you should search for how to send emails directly or check this

How can I implement italic HTML format of text in Android in Yahoo email client, or native mail client

I have to implement a text in italic, so I have used HTML formatting.
In gmail app it works fine but in native mail client, yahoo mail app, or outlook, I cant see italicised text.
below is the sample code:
Html html = null;
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"konypsteam#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "testMail");
//i.putExtra(Intent.EXTRA_TEXT , html.fromHtml(body));
i.putExtra(android.content.Intent.EXTRA_TEXT, html.fromHtml(body));
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
Any help?

How can I send mail from my app with underline or bold text?

My code:
String html = "<html><body><b<bold</b><u>underline</u></body></html>";
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT,
Html.fromHtml(html));
startActivity(Intent.createChooser(intent, "Send Email"));
The result is normal text. Is there a way to make this text bold and underline?
You cannot use the type text/html with Intent.EXTRA_TEXT according to this documentation. Have you tried with EXTRA_STREAM?
On the other hand, you have a HTML sintax error in the bold tag:
String html = "<html><body><b<bold</b><u>underline</u></body></html>";
should be:
String html = "<html><body><b>bold</b><u>underline</u></body></html>";
UPDATE:
It may be a bug in your default email app, have a go with the Gmail app if you can and see what happens. Change the code a bit to choose again your default mail client:
try {
startActivity(Intent.createChooser(intent, "Send mail"));
Log.i("MAIL", "Finished sending email");
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(),
"There is no email client installed.", Toast.LENGTH_SHORT).show();
}
As you can see in the picture below, it works with the default Mail app of the Android framework.
Have you tried for example with the Project Build Target to 4.3?

Sending email programatically using the DEFAULT app

I am developing an app that send programatically an email, Im using stoxk LG mail
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{XXXXXXX});
i.putExtra(Intent.EXTRA_SUBJECT, "XXXXXXXXXX");
i.putExtra(Intent.EXTRA_TEXT , (" XXXXXXXX"));
try {
startActivity(Intent.createChooser(i, "Sending mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast toast = Toast.makeText(getApplicationContext(), "Not found ", Toast.LENGTH_LONG);
toast.show();
finish();
}
It opens the LG mail and pastes the SUBJECT, the TEXT and the MAIL BUT it doesn't send it , how can I achieve it?
Anny suggestion will be apreciated!
With intent you can't do this.
But look at the link, there is an answer for your question.
Sending Email in Android using JavaMail API without using the default android app(Builtin Email application)

Categories

Resources