導航:首頁 > 操作系統 > android發送郵件代碼

android發送郵件代碼

發布時間:2022-12-28 22:28:32

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怎樣不打開系統瀏覽器實現了發送郵件

  1. 下載javamail的java包,加入到你項目的庫中。

  2. 2.修改你的郵箱設置,這里以163郵箱為例。打開設置,開啟客戶端授權碼,記住這個授權碼,然後打開POP3/SMTP服務和IMAP/SMTP服務。

  3. 輸入相應的代碼(私我給你發)

  4. 在使用該庫前先簡單介紹一下 Email for Android 2.3.2 中四個核心的類和相關的方法。

  5. EmailConfig 類

  6. setAccount( ):設置發信人的郵箱(必寫)

  7. setPassword( ) :設置發信人的郵箱密碼或授權碼(必寫)

  8. setSmtpHost( ):設置SMTP伺服器地址(發送郵件時必寫)

  9. setSmtpPort( ):設置SMTP伺服器埠(發送郵件時必寫)

  10. setPopHost( ):設置POP伺服器地址(接收郵件時必寫)

  11. setPopPort( ):設置POP伺服器埠(接收郵件時必寫)

  12. setImapHost:設置IMAP伺服器地址(接收郵件時必寫)

  13. setImapPort:設置IMAP伺服器埠(接收郵件時必寫)

  14. EmailSendClient 類

  15. setTo( ):設置收信人郵箱(必寫)

  16. setCc( ):設置抄送人

  17. setBcc( ):設置密送人

  18. setNickname( ):設置發信人昵稱

  19. setSubject( ):設置郵件主題(必寫)

  20. setText( ):設置文本型的郵件內容(必寫,但 setText( ) 和 setContent( ) 只能二選一)

  21. setContent( ):設置HTML型的郵件內容(同上)

  22. sendAsyn( ):非同步發送郵件(必寫)

  23. EmailReceiveClient 類

  24. popReceiveAsyn( ):使用POP3協議非同步接收郵件

  25. imapReceiveAsyn( ):使用IMAP協議非同步接收郵件

  26. EmailExamine 類

  27. 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"));

閱讀全文

與android發送郵件代碼相關的資料

熱點內容
冒險島什麼伺服器好玩 瀏覽:541
如何在伺服器上做性能測試 瀏覽:793
命令序列錯 瀏覽:257
javaif的條件表達式 瀏覽:576
手機app上傳的照片怎麼找 瀏覽:531
雲伺服器面臨哪些威脅 瀏覽:746
c語言各種編譯特點 瀏覽:177
路由器多種加密方法 瀏覽:604
程序員阻止電腦自動彈出定位 瀏覽:168
如何做伺服器服務商 瀏覽:761
su剖切命令 瀏覽:726
devc編譯背景 瀏覽:211
學習單片機的意義 瀏覽:51
音頻演算法AEC 瀏覽:911
加密貨幣容易被盜 瀏覽:82
蘋果平板如何開啟隱私單個app 瀏覽:704
空調壓縮機一開就停止 瀏覽:528
如何下載虎牙app 瀏覽:847
日語年號的演算法 瀏覽:955
dev裡面的編譯日誌咋調出來 瀏覽:298