I am developing an app in which i want to send mail from app without user intervention.And it is not good to take the user credentials(name,password).So i wrote a service using Web API in .net and the mail was going perfectly.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=lakshmianusha21@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[]{"lakshmianusha21@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();
}
}
Aucun commentaire:
Enregistrer un commentaire