我有一個HTML發送從我的Android application.I電子郵件不想發送此作爲attachment.I希望使用這個電子郵件body.Is顯示它可能JavaMail API?我可以使用javamail發送類似gmail應用程序的電子郵件嗎?如何使用JavaMail API中的Android
感謝
我有一個HTML發送從我的Android application.I電子郵件不想發送此作爲attachment.I希望使用這個電子郵件body.Is顯示它可能JavaMail API?我可以使用javamail發送類似gmail應用程序的電子郵件嗎?如何使用JavaMail API中的Android
感謝
Android中傳送電子郵件很容易使用Intent
機制,沒有理由在一個糟糕的方式做到這一點。
嘗試閱讀this link,有點這個Android的文檔。
在Android中,當你想要做的比你的應用的主要焦點以外的東西,你通常使用一個Intent
,並要求其他應用程序做到這一點。處理此意圖的應用程序通常專注於完成此目標。例如:如果您想撥打電話,通常會將其交給撥號器應用程序,或者如果您想發送電子郵件,請讓GMail或其他電子郵件應用程序處理。做到這一點
最簡單,最推薦的方法是火的意圖。
下面的代碼片段應該爲你做的工作。
Intent mailIntent = new Intent(Intent.ACTION_SEND); // says we want to SEND something
mailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
mailIntent.putExtra(Intent.EXTRA_SUBJECT, "email subject");
mailIntent.putExtra(Intent.EXTRA_TEXT, "message content. Html should go here.");
// Some versions of android, doesn't recognize your intention is to send an email,
// even though you specify the EXTRA_EMAIL and they show all sorts of apps as
// options. Specifying the rfc type fixes this on most devices.
mailIntent.setType("message/rfc822");
// now we fire the intent
startActivity(mailntent);
請注意,Android上的GMail應用程序和默認交換應用程序可能會顯示您的HTML文本。根據我的經驗,如果您在MS Outlook或類似的應用程序中打開發送的文檔,它會識別出郵件使用HTML。
希望這會有所幫助。