1 / 12

課程參與度之評估方式

課程參與度之評估方式. 上課時必須專心聽講,跟上進度,參與討論 扣分項目 玩線上遊戲一次扣 1 分 玩手機一次扣 1 分 睡覺一次扣 1 分 聊天一次扣 1 分 無法回答老師提出的問題一次扣 1 分 加分項目 主動回答老師的問題一次加 2 分 找出老師程式中的錯誤一次加 1 分 修正老師程式中的錯誤一次加 4 分. 網路程式設計 第十四章 JavaMail 電子郵件 API. 鄧姚文. 大綱. 瞭解 email 的傳送與接收流程 認識 email 使用的通訊協定 使用 JavaMail API 實 作送信應用程式與類別 實 作讀信應用程式與類別

nibal
Télécharger la présentation

課程參與度之評估方式

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 課程參與度之評估方式 • 上課時必須專心聽講,跟上進度,參與討論 • 扣分項目 • 玩線上遊戲一次扣1分 • 玩手機一次扣1分 • 睡覺一次扣1分 • 聊天一次扣1分 • 無法回答老師提出的問題一次扣1分 • 加分項目 • 主動回答老師的問題一次加2分 • 找出老師程式中的錯誤一次加1分 • 修正老師程式中的錯誤一次加4分

  2. 網路程式設計第十四章 JavaMail電子郵件API 鄧姚文

  3. 大綱 瞭解email的傳送與接收流程 認識email使用的通訊協定 使用JavaMail API 實作送信應用程式與類別 實作讀信應用程式與類別 整合應用

  4. Email的傳送與接收流程 • 使用者代理軟體 Mail User Agent(MUA) • 使用者操作MUA傳送/接收Email • Outlook/Outlook Express, Thunderbird • 郵件遞送代理 Mail Transfer Agent(MTA) • Email Server • 通訊協定 • POP3: Post Office Protocol - Version 3 • IMAP: Internet Message Access Protocol • SMTP: Simple Mail Transfer Protocol

  5. Email的傳送與接收流程

  6. JavaMailAPI 應用 企業電子報 電子廣告(eDM) 系統日誌 會員確認信 事件或訊息通知

  7. JavaMail API 類別庫 • JavaMailAPI 1.4.4 • 下載點 • 下載 mail.jar • JavaBeans Activation Framework(JAF) • 下載點 • 下載 activation.jar • 在 Eclipse 專案之中 Java Build Path 加入外部 JAR 檔

  8. 系統屬性 Properties props = System.getProperties(); props.put("mail.smtp.host", "msa.hinet.net"); props.put("mail.transport.protocol", "smtp"); session = Session.getDefaultInstance(props); • Key-Value Pair • java.util.Properties • System.getProperties() • javax.mail.Session • javax.mail.internet.InternetAddress • javax.mail.Message

  9. 送信 public void send(String from, String to, String subject, String text) { Message msg = new MimeMessage(session); try { InternetAddressfromAddress = new InternetAddress(from); InternetAddresstoAddress = new InternetAddress(to); msg.setFrom(fromAddress); msg.setRecipient(Message.RecipientType.TO, toAddress); msg.setSubject(subject); msg.setText(text); Transport.send(msg); } catch (AddressException e) { e.printStackTrace(); System.out.println("郵件位址錯誤"); } catch (MessagingException e) { e.printStackTrace(); System.out.println("訊息錯誤"); } }

  10. 收信 public Message[] read(String host, String user, String pw) { Message[] messages = null; try { Store store = session.getStore("pop3"); store.connect(host, user, pw); Folder inbox = store.getFolder("INBOX"); inbox.open(Folder.READ_ONLY); messages = inbox.getMessages(); } catch (NoSuchProviderException e) { e.printStackTrace(); System.out.println("讀信協定錯誤"); } catch (MessagingException e) { e.printStackTrace(); System.out.println("訊息錯誤"); } return messages; }

  11. 以 JTable 顯示表格資料 • Model-View-Controller(MVC) • Separation of concerns • 分工合作,各司己職 • Model:資料、行為 • View:畫面 • Control:接受輸入、呼叫 Model 內的商業邏輯、控制輸出

  12. 本章結束 Q&A討論時間

More Related