Good evening everyone! I am writing this code to send e-mail and SMS from my application, the SMS is sent, but the e-mail is not. `
public void onClick(View v) { switch (v.getId()) { case R.id.btnSms: // TODO Call second activity Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent .putExtra( "sms_body", "Здесь текст и смс прекрасно отправляется!!"); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent); break;
case R.id.btnEmail:
/* Создаем интент с экшеном на отправку */ Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); /* Заполняем данными: тип текста, адрес, сабж и собственно текст письма */ emailIntent.setType("text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{""}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Здесь заголовок"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "здесь тоже текст. Но почему-то письмо никак не хочет отправляться???"); /* Отправляем на выбор!*/ context.startActivity(Intent.createChooser(emailIntent, "Send mail...")); break; default: break;`
Where was the mistake? In the manifest, like all the permissions are prescribed. Maybe for e-mail some separate permission is needed?