Android でアプリケーションを開発しています。アプリケーションからメールを送信する方法がわかりません。
ベストアンサー1
最良かつ最も簡単な方法は、以下を使用することですIntent
。
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
それ以外の場合は、独自のクライアントを作成する必要があります。
RFC822はARPAインターネットテキストメッセージの標準です。https://w3.org/プロトコル/rfc822。