I am developing an app in which i want to send mail from app without user intervention(without using intents).And it is not good to take the user credentials(without using java mail API).But how to bind the body of the mail from android application to Web API.Here is my code.
public void onClick(View v) {
if (v == btnSend) {
String url = "http://app.xyz.com/api/SendMail/SendMail?Emailid=xyz@gmail.com" + "&Subject=" + "&Body=";
if (url != null) {
email = editTextEmail.getText().toString();
subject = editTextSubject.getText().toString();
message = editTextMessage.getText().toString();
final Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{"xyz@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
this.startActivity(Intent.createChooser(emailIntent, "Sending email..."));
}
}catch (Throwable t) {
Toast.makeText(this,
"Request failed try again: " + t.toString(),
Toast.LENGTH_LONG).show();
}
}