ここから次のコードを使用して電子メールを開始しています。
Android: メール インテントを使用してメールを送信すると、送信直前にメッセージを変更できますか?
コードは次のとおりです。
private void sendEmail(String recipient, String subject, String message) {
try {
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
if (recipient != null) emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient});
if (subject != null) emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
if (message != null) emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
} catch (ActivityNotFoundException e) {
// cannot send email for some reason
}
}
携帯電話 (HTC Desire) でテストすると、Exchange/Outlook 電子メールを使用するオプションが表示されません (たとえば、Web 上の電子メール リンクをクリックすると表示されることに注意してください)。
代わりに、「Gmail」と「Evernote - メモの作成」のオプションが表示されます (非常に奇妙です)。
このコードは Gmail で期待どおりに動作します。これはすばらしいことですが、Outlook で動作させるにはコードが必要です。誰が問題が何であるか考えましたか? ありがとう。