【正文】
送成功 { AfxMessageBox(操作失敗.,64)。 } else { AfxMessageBox(郵件發(fā)送成功.,64)。 } delete []addr1。 delete []addr2。 delete []path。 delete []file。 delete []m_receiver。 delete []m_messageInfo。 delete []m_mapifiledesc。 lpfnMAPIFreeBuffer(m_messageInfo)。 lpfnMAPILogoff(a,0,0,0)。 FreeLibrary(result)。 使用Jmail組件實(shí)現(xiàn)接收功能的詳細(xì)設(shè)計(jì)本系統(tǒng)通過Jmail組件實(shí)現(xiàn)郵件的接收。郵件的接收需要通過Jmail組件中的IPOP3Ptr指針和IPOP3Ptr指針對(duì)象的Message指針完成。IPOP3Ptr指針負(fù)責(zé)與郵件服務(wù)器的連接,建立連接后可以通過IPOP3Ptr指針對(duì)象的Message指針來獲得郵件的具體內(nèi)容。IPOP3Ptr指針的Connect函數(shù)實(shí)現(xiàn)與郵件服務(wù)器的連接,Connect函數(shù)的參數(shù)包括Username、Password、Server、Port,分別是登陸的用戶名、登陸密碼、POP服務(wù)器、服務(wù)器端口。Message指針的Count屬性能獲得郵件的數(shù)量,Message指針的Item屬性就是郵件文件。實(shí)現(xiàn)的步驟如下:(1),并使用命名空間。代碼如下:import using namespace jmail。(2)在收件箱對(duì)話框的OnRefurbish方法,使用Jmail組件實(shí)現(xiàn)接收電子郵件。代碼如下:CString strpop = ServerMail。//服務(wù)器CString strusr = UserMail。//用戶名CString strpwd = PwdMail。//密碼CString sql。jmail::IPOP3Ptr jpop。//IPOP3Ptr指針(__uuidof(jmail::POP3))。//創(chuàng)建對(duì)象實(shí)例try { jpopTimeout=120。jpopConnect((_bstr_t)strusr,(_bstr_t)strpwd,(_bstr_t)strpop,110)。//連接服務(wù)器 long mailcount=jpopMessagesCount。 for(int i=1。imailcount。i++) {CString from = (char*)jpopMessagesItem[i]From。//發(fā)件人CString recipients = (char*)jpopMessagesItem[i]GetRecipientsString()。//收件人CString bssubject = (char*)jpopMessagesItem[i]Subject。//主題CString sort。CString mailuid = (char*)jpopGetMessageUID(i)。//郵件UIDint index = (TO:)。if(index != 1) sort = (()index3)。else sort = 其他。CString bsbody = (char*)jpopMessagesItem[i]Body。//郵件內(nèi)容COleDateTime time = jpopMessagesItem[i]Date。//接收時(shí)間long count = jpopMessagesItem[i]GetAttachments()GetCount()。//附件數(shù)量CString Attachments = 。 for(int j=0。jcount。j++) { Attachments = (char*)jpopMessagesItem[i]GetAttachments()GetItem(j)GetName()。//附件名 (select * from tb_receivebox where 郵件UID =39。%s39。and 郵箱用戶=39。%s39。,mailuid,UserMail)。 if(IsReceiveMail(sql))//判斷是否為新郵件 { CString filepath。 filepath = path。 filepath += \\附件\\。 filepath += mailuid。 filepath += Attachments。 jpopMessagesItem[i]GetAttachments()GetItem(j) SaveToFile((_bstr_t)filepath)。//存儲(chǔ)附件 } }}}5 測試分析本文對(duì)系統(tǒng)的登陸模塊及主界面、寫信模塊、收件箱模塊、草稿箱模塊、垃圾箱模塊及通信錄模塊都進(jìn)行測試。(1) 登陸模塊、主界面模塊和添加分類模塊測試運(yùn)行程序,打開程序登錄界面。輸入服務(wù)器名稱、郵箱及郵箱密碼,單擊“登錄”按鈕,即可進(jìn)入程序主界面。在主界面中顯示了各個(gè)信箱中的郵件信息,包括郵件總數(shù)和新郵件數(shù),單擊左側(cè)的按鈕可進(jìn)入相應(yīng)的信箱。:登錄界面:主界面單擊登錄界面中的“添加分類”按鈕,進(jìn)入添加郵件分類模塊。輸入菜單名稱,菜單標(biāo)識(shí)自動(dòng)增加,然后單擊“確定”按鈕即可。菜單分類主要是對(duì)接收到的郵件進(jìn)行分類管理。要想對(duì)郵件進(jìn)行分類,必須讓發(fā)送者了解您的分類格式,當(dāng)對(duì)方給您發(fā)送郵件時(shí),在主題后面加上“TO:”+分類名稱即可,例如:“TO:文件”,則接收郵件后程序自動(dòng)將該封郵件分到“文件”類中,當(dāng)選擇“分類”菜單中的“文件”時(shí),自動(dòng)會(huì)顯示在列表中。:“添加分類”按鈕:“分類”菜單(2) 寫信模塊單擊“寫信”按鈕,進(jìn)入寫信頁面。輸入收件人郵箱地址,也可以單擊“選擇聯(lián)系人”按鈕選擇聯(lián)系人,通過“添加附件”和“刪除附件”按鈕可設(shè)置發(fā)送附件,單擊 “發(fā)送”按鈕即可發(fā)送郵件。郵件發(fā)送成功后,在發(fā)件箱中將會(huì)記錄。:寫信頁面(3) 收件箱模塊單擊“收件箱”導(dǎo)航按鈕,進(jìn)入收件箱頁面。單擊“刷新”按鈕可接收新郵件,勾選郵件前的復(fù)選框,單擊“查看”按鈕,可查看該郵件內(nèi)容。:收件箱頁面(4) 草稿箱模塊單擊“草稿箱”導(dǎo)航按鈕,進(jìn)入草稿箱頁面。草稿箱用來保存用戶編輯好但是沒有發(fā)送的郵件,用戶可以在草稿箱中查看郵件信息,并可以進(jìn)行發(fā)送。:草稿箱頁面(5) 垃圾箱模塊單擊“垃圾箱”導(dǎo)航按鈕,進(jìn)入垃圾箱頁面。垃圾箱主要用來保存從收件箱中刪除的郵件。:垃圾箱頁面(6) 通信錄模塊單擊“通訊錄”導(dǎo)航按鈕,單擊“添加”按鈕,可添加聯(lián)系人,單擊“編輯”按鈕,可編輯聯(lián)系人信息,單擊“刪除”按鈕,可刪除聯(lián)系人。其中添加按鈕有兩個(gè)子窗體組成。:通信錄頁面:添加聯(lián)系人頁面:添加分組頁面6 總結(jié)本客戶端電子郵件軟件在功能上基本符合用戶需求,能夠完成發(fā)送郵件和接收郵件的基本操作。但因知識(shí)水平及時(shí)間關(guān)系等各方面的原因,該系統(tǒng)還有許多不盡如人意的地方。本系統(tǒng)所運(yùn)用Jmail組件和MAPI函數(shù)實(shí)現(xiàn)郵件收發(fā)功能的代碼是在本人的師兄關(guān)某某的指導(dǎo)下完成的,由于時(shí)間緊迫所以一些服務(wù)器及相關(guān)電子郵件協(xié)議并未有透徹的理解,系統(tǒng)在功能方面也沒有考慮得很周到。該系統(tǒng)界面的美觀性和出錯(cuò)處理不夠等多方面的問題,這些都有待進(jìn)一步改善。另外,作為客戶端電子管理軟件,登錄的郵箱應(yīng)該多元化,本系統(tǒng)只提供單一的郵箱登陸,系統(tǒng)的進(jìn)一步工作應(yīng)該是實(shí)現(xiàn)多個(gè)郵箱同時(shí)登錄,在同一時(shí)間管理用戶多個(gè)電子郵箱,滿足用戶繁忙的信息通信要求。以上都是自己在開發(fā)的過程中做得不夠好的地方,在這簡單的總結(jié),同時(shí)給自己一個(gè)告誡,希望自己以后考慮問題能做到全面化。參 考 文 獻(xiàn)[1]信息化 [2] 電子郵件 [3]Windows Live Mail Desktop [4] Koomail [5] 夢(mèng)幻快車 [6] Foxmail [7] 譚浩強(qiáng). Visual C++:清華大學(xué)出版社 2004[8] : 高等教育出版社 2005[9] :電子工業(yè)出版社 2006[10] :華中理工大學(xué)出版社 2001[11] Windows應(yīng)用程序設(shè)計(jì)(第2版).北京:清華大學(xué)出版社 2007[12] :人民郵電出版社 2007Design and Implement of Email Client SystemLiang Weitang(Computer Science and Engineering Department Zhongkai University of Agriculture and Technology, Guangzhou 510225,China)Abstract:With the deepening of reform and opening up the development of the establishment of a socialist market economy, information technology is accelerating the pace of the times.According to the latest release of the 20062020 national development strategies, information technology is the full use of information technology, development and utilization of information resources, facilitate the exchange of information and knowledgesharing and improve the quality of economic growth, promoting economic and social development of the historical process of transition.Email is the Internet network, as well as all other network system for the direct exchange of information between the systems, its data sender and the recipient are all human, so great to meet a lot of people there munications needs.In this paper, indepth understanding of the practical operation of management process on the basis of summing up the life of monly used functions, objectoriented programming using design thinking and the development of a simple, convenient client software, the realization of electronic Email the flexibility in management.Key words:Email Client Jmail groupware3