① 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( ):檢查郵件伺服器配
② 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了。其實還是很簡單的。
③ Android開發,各位大神誰知道怎麼在後台發Email或發簡訊,不用跳轉到系統界面,感激不盡!
郵件可以使用java mail api, 發簡訊就直接調用Android api SmsManager.sendMessage()就行
④ Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
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中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.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);
發送多個附件,最主要的時候,通過putParcelableArrayListExtra將多個附件的Uri地址List設置進去。
⑤ 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"));
⑥ Android開發中怎樣調用系統Email發送郵件
您好,很高興為您解答。
Android調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
調用Email是Email可以接收Intent並做這些事情,可能也有其他的應用程序實現相關功能,所以在執行的時候,會出現選擇框進行選擇。
1、使用SENTTO發送使用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設置進去
如若滿意,請點擊右側【採納答案】,如若還有問題,請點擊【追問】
希望我的回答對您有所幫助,望採納!
~O(∩_∩)O~
⑦ 如何設置Android系統的郵件客戶端收發郵件
1.打開程序列表 > 選擇「郵件」,某些android系統顯示為「電子郵件」,打開設置 >「賬戶列表」> 選擇「新建賬戶」,頁面點擊「其他(POP3/IMAP)」
2.首先輸入您的郵箱地址和密碼,然後點擊「手動設置」
3.在「接收郵件伺服器設置」頁面,設置接收郵件伺服器的信息,以及郵件地址、用戶名和密碼,用戶名欄位可以任意填寫。(註:所有項均為必填項,特別要注意一定要填寫發件人的用戶名及密碼)
接收郵件伺服器:
協議:選擇「POP」頁簽。
電子郵件地址:請填寫您的郵箱帳戶全名。
用戶名:請填寫您的郵箱帳戶全名。
密碼:請填寫您的郵箱密碼
POP伺服器:請填寫POP地址(點此查詢客戶端配置地址)
伺服器埠:參數設置為:110。
如果您的郵件收發需要採用SSL加密,「安全類型」選擇SSL,伺服器埠參數設置為:1995。
4.點擊下一步,在「發送郵件伺服器設置」頁面設置發件伺服器的信息(註:所有項均為必填項,特別要注意一定要填寫發件人的用戶名及密碼)
發送伺服器:
用戶名:請填寫您的郵箱帳戶全名。
密碼:請填寫您的郵箱密碼。
SMTP伺服器:請填寫SMTP地址。(點此查詢客戶端配置地址)
伺服器埠:參數設置為:25。
如果您的郵件收發需要採用SSL加密,「安全類型」選擇SSL,伺服器埠參數設置為:465。
5.點擊「下一步」,如您需要修改姓名,請點擊「您的姓名」輸入欄輸入,如果勾選了「設為我的默認賬戶」則此賬戶會設置為手機郵件的默認賬戶。
6.點擊結束設置,接下來您就可以在手機上進行郵件的收發了。
⑧ 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"));
⑨ Android開發中怎樣調用系統Email發送郵件
在Android中,調用Email有三種類型的Intent:
Intent.ACTION_SENDTO 無附件的發送
Intent.ACTION_SEND 帶附件的發送
Intent.ACTION_SEND_MULTIPLE 帶有多附件的發送
【方法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);
【方法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);
⑩ 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了。其實還是很簡單的。