A. android開發中怎樣調用系統Email發送郵件
您好,很高興為您解答。
Android調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
調用Email是Email可以接收Intent並做這些事情,可能也有其他的應用程序實現相關功能,所以在執行的時候,會出現選擇框進行選擇。
1、使用SENTTO發送使用SENTTO發送
java">Intentdata=newIntent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT,"這是標題");
data.putExtra(Intent.EXTRA_TEXT,"這是內容");
startActivity(data);
Intentdata=newIntent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT,"這是標題");
data.putExtra(Intent.EXTRA_TEXT,"這是內容");
startActivity(data);
通過向Intent中putExtra來設定郵件的相關參數。
2、使用SEND發送
Intentintent=newIntent(Intent.ACTION_SEND);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
String[]bccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_BCC,bccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///mnt/sdcard/a.jpg"));
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
Intentintent=newIntent(Intent.ACTION_SEND);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
String[]bccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_BCC,bccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///mnt/sdcard/a.jpg"));
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
分別通過Intent.EXTRA_EMAIL,
Intent.EXTRA_CC,
Intent.EXTRA_BCC
進行putExtra來設定。單個附件的發送,使用Intent.EXTRA_STREAM來設置附件的地址Uri。
3、使用SEND_MULTIPLE來進行多附件的發送
Intentintent=newIntent(Intent.ACTION_SEND_MULTIPLE);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
ArrayList<uri>imageUris=newArrayList<uri>();
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"));
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
Intentintent=newIntent(Intent.ACTION_SEND_MULTIPLE);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
ArrayList<uri>imageUris=newArrayList<uri>();
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"));
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
發送多個附件,通過putParcelableArrayListExtra將多個附件的Uri地址List設置進去
如若滿意,請點擊右側【採納答案】,如若還有問題,請點擊【追問】
希望我的回答對您有所幫助,望採納!
~O(∩_∩)O~
B. Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent: Intent")); data")); data" }; String[] ccs = { "way" }; String[] bccs = {"way"}; intent" }; String[] ccs = { "way" }; String[] bccs = {"way"}; intent" }; String[] ccs = { "way" }; intent" }; String[] ccs = { "way" }; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_TEXT, "body"); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); ArrayList<uri> imageUris = new ArrayList<uri>(); imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg")); imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg")); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); intent.setType("image/*"); intent.setType("message/rfc882"); Intent.createChooser(intent, "Choose Email Client"); startActivity(intent);
C. Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
Intent data=new Intent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT, "這是標題");
data.putExtra(Intent.EXTRA_TEXT, "這是內容");
startActivity(data);
這只是其中的一種方法
D. Android開發中怎樣調用系統Email發送郵件
Stringaddress="[email protected]";//收件人地址
Intentdata=newIntent(Intent.ACTION_SENDTO);
data.setData(Uri.parse(address));
data.putExtra(Intent.EXTRA_SUBJECT,"這是標題");
data.putExtra(Intent.EXTRA_TEXT,"這是內容");
try
{
startActivity(data);
}catch(ActivityNotFoundExceptione)
{
Toast.maketext(MainActivity.this,"還沒有安裝郵箱軟體啊",0).show();
}
參考:http://www.jb51.net/article/38158.htm
E. 如何從我的android應用程序發郵件
這真是個有意思的問題
如果你只是Android的使用者,我建議你點開系統自帶的Email app或者你自己下載的第三方郵件app 按照應用的提示發送郵件
如果你是初級開發者,我建議你使用Intent mailto 協議調用系統郵件系統發送郵件
如果你比初級開發水平好點(比如說中級開發?),我建議使用第三方libs (如mail.jar)自行編寫代碼實現自動發送郵件
如果你是高級開發者,額,如果真的是的話,你不會提這種問題,至少不會在這里提問
F. android怎樣不打開系統瀏覽器實現了發送郵件
下載javamail的java包,加入到你項目的庫中。
2.修改你的郵箱設置,這里以163郵箱為例。打開設置,開啟客戶端授權碼,記住這個授權碼,然後打開POP3/SMTP服務和IMAP/SMTP服務。
輸入相應的代碼(私我給你發)
在使用該庫前先簡單介紹一下 Email for Android 2.3.2 中四個核心的類和相關的方法。
EmailConfig 類
setAccount( ):設置發信人的郵箱(必寫)
setPassword( ) :設置發信人的郵箱密碼或授權碼(必寫)
setSmtpHost( ):設置SMTP伺服器地址(發送郵件時必寫)
setSmtpPort( ):設置SMTP伺服器埠(發送郵件時必寫)
setPopHost( ):設置POP伺服器地址(接收郵件時必寫)
setPopPort( ):設置POP伺服器埠(接收郵件時必寫)
setImapHost:設置IMAP伺服器地址(接收郵件時必寫)
setImapPort:設置IMAP伺服器埠(接收郵件時必寫)
EmailSendClient 類
setTo( ):設置收信人郵箱(必寫)
setCc( ):設置抄送人
setBcc( ):設置密送人
setNickname( ):設置發信人昵稱
setSubject( ):設置郵件主題(必寫)
setText( ):設置文本型的郵件內容(必寫,但 setText( ) 和 setContent( ) 只能二選一)
setContent( ):設置HTML型的郵件內容(同上)
sendAsyn( ):非同步發送郵件(必寫)
EmailReceiveClient 類
popReceiveAsyn( ):使用POP3協議非同步接收郵件
imapReceiveAsyn( ):使用IMAP協議非同步接收郵件
EmailExamine 類
connectServer( ):檢查郵件伺服器配
G. Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
當然,所謂的調用Email,只是說Email可以接收Intent並做這些事情,可能也有其他的應用程序實現了相關功能,所以在執行的時候,會出現選擇框進行選擇。
1.使用SENTTO發送
Intentdata=newIntent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT,"這是標題");
data.putExtra(Intent.EXTRA_TEXT,"這是內容");
startActivity(data);
Intentdata=newIntent(Intent.ACTION_SENDTO);
data.setData(Uri.parse("mailto:[email protected]"));
data.putExtra(Intent.EXTRA_SUBJECT,"這是標題");
data.putExtra(Intent.EXTRA_TEXT,"這是內容");
startActivity(data);
通過向Intent中putExtra來設定郵件的相關參數。
2.使用SEND發送
Intentintent=newIntent(Intent.ACTION_SEND);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
String[]bccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_BCC,bccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///mnt/sdcard/a.jpg"));
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
Intentintent=newIntent(Intent.ACTION_SEND);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
String[]bccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_BCC,bccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///mnt/sdcard/a.jpg"));
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
很簡單,發送郵件中,有收件者,抄送者,密送者。 也就是分別通過
Intent.EXTRA_EMAIL,
Intent.EXTRA_CC,
Intent.EXTRA_BCC
來進行putExtra來設定的,而單個附件的發送,則使用Intent.EXTRA_STREAM來設置附件的地址Uri。
3.使用SEND_MULTIPLE來進行多附件的發送
Intentintent=newIntent(Intent.ACTION_SEND_MULTIPLE);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
ArrayList<uri>imageUris=newArrayList<uri>();
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"));
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
Intentintent=newIntent(Intent.ACTION_SEND_MULTIPLE);
String[]tos={"[email protected]"};
String[]ccs={"[email protected]"};
intent.putExtra(Intent.EXTRA_EMAIL,tos);
intent.putExtra(Intent.EXTRA_CC,ccs);
intent.putExtra(Intent.EXTRA_TEXT,"body");
intent.putExtra(Intent.EXTRA_SUBJECT,"subject");
ArrayList<uri>imageUris=newArrayList<uri>();
imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg"));
imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg"));
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris);
intent.setType("image/*");
intent.setType("message/rfc882");
Intent.createChooser(intent,"ChooseEmailClient");
startActivity(intent);
發送多個附件,最主要的時候,通過putParcelableArrayListExtra將多個附件的Uri地址List設置進去就OK了。其實還是很簡單的。
H. Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent: Intent.ACTION_SENDTO 無附件的發送 Intent.ACTION_SEND 帶附件的發送 Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送 當然,所謂的調用Email,只是說Email可以接收Intent並做這些事情,可能也有其他的應用程序實現了相關功能,所以在執行的時候,會出現選擇框進行選擇。 1.使用SENTTO發送
Intent data=new Intent(Intent.ACTION_SENDTO); data.setData(Uri.parse("mailto:[email protected]")); data.putExtra(Intent.EXTRA_SUBJECT, "這是標題"); data.putExtra(Intent.EXTRA_TEXT, "這是內容"); startActivity(data); Intent data=new Intent(Intent.ACTION_SENDTO); data.setData(Uri.parse("mailto:[email protected]")); data.putExtra(Intent.EXTRA_SUBJECT, "這是標題"); data.putExtra(Intent.EXTRA_TEXT, "這是內容"); startActivity(data);
通過向Intent中putExtra來設定郵件的相關參數。 2.使用SEND發送
Intent intent = new Intent(Intent.ACTION_SEND); String[] tos = { "[email protected]" }; String[] ccs = { "[email protected]" }; String[] bccs = {"[email protected]"}; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_BCC, bccs); intent.putExtra(Intent.EXTRA_TEXT, "body"); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/a.jpg")); intent.setType("image/*"); intent.setType("message/rfc882"); Intent.createChooser(intent, "Choose Email Client"); startActivity(intent); Intent intent = new Intent(Intent.ACTION_SEND); String[] tos = { "[email protected]" }; String[] ccs = { "[email protected]" }; String[] bccs = {"[email protected]"}; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_BCC, bccs); intent.putExtra(Intent.EXTRA_TEXT, "body"); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/a.jpg")); intent.setType("image/*"); intent.setType("message/rfc882"); Intent.createChooser(intent, "Choose Email Client"); startActivity(intent);
很簡單,發送郵件中,有收件者,抄送者,密送者。 也就是分別通過 Intent.EXTRA_EMAIL, Intent.EXTRA_CC, Intent.EXTRA_BCC 來進行putExtra來設定的,而單個附件的發送,則使用Intent.EXTRA_STREAM來設置附件的地址Uri。 3.使用SEND_MULTIPLE來進行多附件的發送
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); String[] tos = { "[email protected]" }; String[] ccs = { "[email protected]" }; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_TEXT, "body"); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); ArrayList<uri> imageUris = new ArrayList<uri>(); imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg")); imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg")); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); intent.setType("image/*"); intent.setType("message/rfc882"); Intent.createChooser(intent, "Choose Email Client"); startActivity(intent); Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); String[] tos = { "[email protected]" }; String[] ccs = { "[email protected]" }; intent.putExtra(Intent.EXTRA_EMAIL, tos); intent.putExtra(Intent.EXTRA_CC, ccs); intent.putExtra(Intent.EXTRA_TEXT, "body"); intent.putExtra(Intent.EXTRA_SUBJECT, "subject"); ArrayList<uri> imageUris = new ArrayList<uri>(); imageUris.add(Uri.parse("file:///mnt/sdcard/a.jpg")); imageUris.add(Uri.parse("file:///mnt/sdcard/b.jpg")); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imageUris); intent.setType("image/*"); intent.setType("message/rfc882"); Intent.createChooser(intent, "Choose Email Client"); startActivity(intent);
發送多個附件,最主要的時候,通過putParcelableArrayListExtra將多個附件的Uri地址List設置進去就OK了。其實還是很簡單的。
I. Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
如:
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
//設置文本格式
emailIntent.setType("text/plain");
//設置對方郵件地址
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "");
//設置標題內容
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getString(R.string.setting_recommend_words));
//設置郵件文本內容
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,getString(R.string.setting_recommend_words));
startActivity(Intent.createChooser(emailIntent,"Choose Email Client"));