【正文】
圖49所示。在進(jìn)行好友分組操作時(shí),對(duì)郵箱中的Email是逐個(gè)進(jìn)行處理的,本文詳細(xì)介紹某個(gè)Email的詳細(xì)處理過程,至于所有的Email只要根據(jù)條件進(jìn)行一個(gè)循環(huán)就可以了。圖49 按好友分組樹狀圖動(dòng)態(tài)產(chǎn)生效果圖動(dòng)態(tài)生成樹狀結(jié)果的程序?qū)崿F(xiàn)代碼如下所示://初始化分類結(jié)果顯示 m_RecordsetPtr = (select * from book)。 CString name,。 HTREEITEM hItem2_f1。 while(!m_RecordsetPtradoEOF) { BOOL flag =FALSE。 name=(LPCTSTR)((_bstr_t)m_RecordsetPtrGetCollect(name))。 = (LPCTSTR)((_bstr_t)m_RecordsetPtrGetCollect())。 hItem2_f1= (name,0,1,hItem2_f,TVI_LAST)。 for (int j=0。jleng。j++) { if (((CMessages *)[j])strFrom==) { subject = ((CMessages *)[j])strSubject。 (subject,0,1,hItem2_f1,TVI_LAST)。 flag = TRUE。 break。 } } m_RecordsetPtrMoveNext()。 }BOOL falg。for (int j=0。jleng。j++) { falg = FALSE。 m_RecordsetPtrMoveFirst()。 while(!m_RecordsetPtradoEOF) { name=(LPCTSTR)((_bstr_t)m_RecordsetPtrGetCollect(name))。 = (LPCTSTR)((_bstr_t)m_RecordsetPtrGetCollect())。 if (((CMessages *)[j])strFrom==) { falg = TRUE。 break。 } m_RecordsetPtrMoveNext()。 } if (falg==TRUE) { continue。 } if (falg == FALSE) { subject = ((CMessages *)[j])strSubject。 (subject,0,1,hItem2_m,TVI_LAST)。 } }當(dāng)雙擊某個(gè)Email時(shí),在郵件列表框中顯示出該Email列表的程序?qū)崿F(xiàn)代碼如下所示: ()。 for (int i=0。ileng。i++) { if (((CMessages *)[i])strSubject==S1) { date = ((CMessages *)[i])strTime。 subject = ((CMessages *)[i])strSubject。 from = ((CMessages *)[i])strFrom。 int nListItem = (i, from)。 (nListItem, 1, LVIF_TEXT, subject, 0, 0, 0, NULL)。 (nListItem, 2, LVIF_TEXT, date, 0, 0, 0, NULL)。 } }一個(gè)Email的處理過程如下:從數(shù)據(jù)庫中取出所有好友信息的記錄集,將Email中的來源和數(shù)據(jù)庫中的所有記錄集進(jìn)行比較,若Email中的來源和數(shù)據(jù)庫記錄集中的某個(gè)Email地址字段相等,則說明該Email是好友的Email,再從數(shù)據(jù)庫中查看是哪個(gè)好友的,并將該Email添加到該好友的分組中,只要找到了該Email是某個(gè)好友的就結(jié)束該郵件的分組,若不是好友發(fā)送的Email則就放到陌生郵件分組中。之后繼續(xù)分析下一個(gè)Email。按好友分組處理過程的流程圖如圖410所示:圖410 按好友分組處理流程圖在進(jìn)行好友分組之后,對(duì)Email的操作過程類似與按時(shí)間分組,雙擊某個(gè)Email時(shí)就會(huì)在Email列表框控件中顯示該Email的相關(guān)信息,當(dāng)點(diǎn)擊該Email時(shí)就可以在相應(yīng)的文本框中顯示出該Email的正文。在點(diǎn)擊郵件列表中相關(guān)信息時(shí)在相應(yīng)控件中顯示該Email正文的主要實(shí)現(xiàn)是要通過一個(gè)消息處理來實(shí)現(xiàn)的。該實(shí)現(xiàn)方法類似與在時(shí)間分組中顯示該Email的方法是一樣的。用的也是同一個(gè)函數(shù)。 添加好友信息該系統(tǒng)在給每個(gè)用戶使用時(shí),好友列表是空的,這就以為這在添加好友信息之前,實(shí)現(xiàn)Email的按好友分組功能是沒有任何意義的。該功能是實(shí)現(xiàn)不了的。這就要求用戶若想實(shí)現(xiàn)Email按好友進(jìn)行分組的話就必須添加好友信息。也就是說這一步是實(shí)現(xiàn)Email按好友分組的前提,該功能在該系統(tǒng)中的作用就可想而知了。在添加好友信息時(shí),本文的做法是在填寫完相關(guān)的好友信息之后將輸入的相關(guān)字符串存入Access數(shù)據(jù)庫的相應(yīng)表格中。該部分實(shí)現(xiàn)比較簡(jiǎn)單,主要實(shí)現(xiàn)代碼如下所示: CString name,。 (name)。 ()。 CString strSQL。 (insert into book values(39。%s39。,39。%s39。),name,)。 (strSQL)。 AfxMessageBox(添加成功!)。 (select * from book )。 if(this() != TRUE)//連接數(shù)據(jù)庫 AfxMessageBox(error ,database unconnect!)。 m_RecordsetPtr= (strSQL)。 show(m_RecordsetPtr)。 5 程序調(diào)試本文所設(shè)計(jì)的程序開始在調(diào)試時(shí)出現(xiàn)了很多問題,比如Email刪除不正確,分析其主要原因如下:(1) 在進(jìn)行刪除時(shí)連接已經(jīng)關(guān)閉了,在進(jìn)行刪除時(shí)出現(xiàn)了非法操作。(2) 在進(jìn)行Email刪除時(shí),需要一個(gè)ID,由于此ID出現(xiàn)錯(cuò)誤而導(dǎo)致誤刪Email(3) 在進(jìn)行Email分析時(shí)由于沒有從郵件列表中將該Email的信息刪除,導(dǎo)致刪除了的信息在再次分析時(shí)在垃圾Email列表中顯示出來了。(4) 在進(jìn)行Email多次分析時(shí)由于存儲(chǔ)惡意Email的集合類中的信息沒有刪除導(dǎo)致惡意Email重復(fù)顯示在惡意Email列表框中。上述問題只是在進(jìn)行程序編寫過程中遇到的一部分問題。通過這些錯(cuò)誤的調(diào)試,我學(xué)到了如何高效快速得調(diào)試程序并及時(shí)發(fā)現(xiàn)錯(cuò)誤所在。通過調(diào)試發(fā)現(xiàn)斷點(diǎn)調(diào)試很重要,通過VC自帶的調(diào)試工具可以很快地找到錯(cuò)誤。在進(jìn)行斷點(diǎn)調(diào)試時(shí)可以觀察相關(guān)變量的值以發(fā)現(xiàn)錯(cuò)誤所在。在程序調(diào)試過程中我只學(xué)到了一些最基本的方法。如何正確高效地實(shí)用調(diào)試工具還將在以后的工作學(xué)習(xí)中繼續(xù)學(xué)習(xí)。6 結(jié)論與展望本文所設(shè)計(jì)的Email分析系統(tǒng)能夠從Email服務(wù)器上接收到郵件,并通過關(guān)鍵字查找方式分析惡意Email,給用戶參考,最終是否刪除該Email由用戶決定,這樣做提高了系統(tǒng)的可靠性和安全性,不會(huì)誤刪用戶有用的Email。而且用戶可以根據(jù)自己的需要添加關(guān)鍵字,這樣為系統(tǒng)的可擴(kuò)展性奠定了一個(gè)好的基礎(chǔ)。在進(jìn)行郵件分組的時(shí)候,基于時(shí)間的分組方法及基于好友的分組方法。這兩種方法在優(yōu)缺點(diǎn)上進(jìn)行了互補(bǔ),給用戶對(duì)Email的管理帶來了極大的便利性。好友信息可以通過用戶自己添加。該系統(tǒng)能夠很好地實(shí)現(xiàn)分組及惡意Email的分析功能,并且具有很好的可擴(kuò)展性,達(dá)到了預(yù)期的設(shè)計(jì)目標(biāo)。從長(zhǎng)遠(yuǎn)的發(fā)展來看,本文所設(shè)計(jì)的系統(tǒng)還應(yīng)加入一個(gè)學(xué)習(xí)機(jī)的功能,只有這樣Email分析系統(tǒng)才能夠更智能化,需要人工干預(yù)的程序比較少。Email分析系統(tǒng)的發(fā)展任重而道遠(yuǎn)。前途一片光明,相信在不久的將來更智能化的Email分析系統(tǒng)會(huì)展現(xiàn)在我們的面前。參考文獻(xiàn)[1] [M].北京:電子工業(yè)出版社, 2005: 120133.[2] [M].北京:清華大學(xué)出版社, 2002: 1518.[3] [M].北京:人民郵電出版社, 2000: 8996.[4] [M].北京:電子工業(yè)出版社, 2006: 100108.[5] [M].北京:人民郵電出版社, 2004: 6670.[6] [M].北京:電子工業(yè)出版社, 2003: 2146.[7] [M].北京:中國青年出版社, 2003: 3050.[8] [M].天津:機(jī)械工業(yè)出版社, 2006: 6688.[9] Deborah. Email Principle and Analysis[M]. USA: University of California Press, 2002: 3356.[10] Patrick. Malicious Email and Antispam Technology and Research[M]. USA: University of Chicago Press, 2003: 6589.致 謝本文是在徐明導(dǎo)師的幫助下完成的,在進(jìn)行系統(tǒng)設(shè)計(jì)時(shí)同學(xué)和朋友也給予了我很大的幫助,特別是在我剛開始接觸編程的時(shí)候遇到了很多的問題,在同學(xué)和朋友的幫助下問題一一得到解決,再此特別感謝他們的幫助。 Anyway, I was here in Amber some years ago. Not doing much of anything. Just visiting and being a nuisance. Dad was still around, and when I noticed that he was getting into one of his grumpy moods, I decided it was time to take a walk. A long one. I had often noticed that his fondness for me tended to increase as an inverse function of my proximity. He gave me a fancy riding crop for a goingaway presentto hasten the process of affection, I suppose. Still, it was a very nice cropsilverchased, beautifully tooledand I made good use of it. I had decided to go looking for an assemblage of all my simple pleasures in one small nook of Shadow. It was a long rideI will not bore you with the detailsand it was pretty far from Amber, as such things go. This time, I was not looking for a place where I would be especially important. That can get either boring or difficult fairly quickly, depending on how responsible you want to be. I wanted to be an irresponsible nonentity and just enjoy myself. Texorami was a wide open port city, with sultry days and long nights, lots of good music, gambling around the clock, duels every morning and inbetween mayhem for those who couldn39。t wait. And the air currents were fabulous. I had a little red sail plane I used to go sky surfing in, every couple of days. It was the good life. I played drums till all hours in a basement spot up the river where the walls sweated almost as much as the customers and the smoke used to wash around the lights like streams of milk. When I was done playing I39。d go find some action, women, or cards, usually. And that was it for the rest of the night. Damn Eric, anywayl That reminds me again . . . He once accused me of cheating at cards, did you know that? And that39。s about the only thing I wouldn39。t cheat at. I take my card playing