【正文】
圖49所示。在進行好友分組操作時,對郵箱中的Email是逐個進行處理的,本文詳細介紹某個Email的詳細處理過程,至于所有的Email只要根據(jù)條件進行一個循環(huán)就可以了。圖49 按好友分組樹狀圖動態(tài)產生效果圖動態(tài)生成樹狀結果的程序實現(xiàn)代碼如下所示://初始化分類結果顯示 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)。 } }當雙擊某個Email時,在郵件列表框中顯示出該Email列表的程序實現(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)。 } }一個Email的處理過程如下:從數(shù)據(jù)庫中取出所有好友信息的記錄集,將Email中的來源和數(shù)據(jù)庫中的所有記錄集進行比較,若Email中的來源和數(shù)據(jù)庫記錄集中的某個Email地址字段相等,則說明該Email是好友的Email,再從數(shù)據(jù)庫中查看是哪個好友的,并將該Email添加到該好友的分組中,只要找到了該Email是某個好友的就結束該郵件的分組,若不是好友發(fā)送的Email則就放到陌生郵件分組中。之后繼續(xù)分析下一個Email。按好友分組處理過程的流程圖如圖410所示:圖410 按好友分組處理流程圖在進行好友分組之后,對Email的操作過程類似與按時間分組,雙擊某個Email時就會在Email列表框控件中顯示該Email的相關信息,當點擊該Email時就可以在相應的文本框中顯示出該Email的正文。在點擊郵件列表中相關信息時在相應控件中顯示該Email正文的主要實現(xiàn)是要通過一個消息處理來實現(xiàn)的。該實現(xiàn)方法類似與在時間分組中顯示該Email的方法是一樣的。用的也是同一個函數(shù)。 添加好友信息該系統(tǒng)在給每個用戶使用時,好友列表是空的,這就以為這在添加好友信息之前,實現(xiàn)Email的按好友分組功能是沒有任何意義的。該功能是實現(xiàn)不了的。這就要求用戶若想實現(xiàn)Email按好友進行分組的話就必須添加好友信息。也就是說這一步是實現(xiàn)Email按好友分組的前提,該功能在該系統(tǒng)中的作用就可想而知了。在添加好友信息時,本文的做法是在填寫完相關的好友信息之后將輸入的相關字符串存入Access數(shù)據(jù)庫的相應表格中。該部分實現(xiàn)比較簡單,主要實現(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 程序調試本文所設計的程序開始在調試時出現(xiàn)了很多問題,比如Email刪除不正確,分析其主要原因如下:(1) 在進行刪除時連接已經關閉了,在進行刪除時出現(xiàn)了非法操作。(2) 在進行Email刪除時,需要一個ID,由于此ID出現(xiàn)錯誤而導致誤刪Email(3) 在進行Email分析時由于沒有從郵件列表中將該Email的信息刪除,導致刪除了的信息在再次分析時在垃圾Email列表中顯示出來了。(4) 在進行Email多次分析時由于存儲惡意Email的集合類中的信息沒有刪除導致惡意Email重復顯示在惡意Email列表框中。上述問題只是在進行程序編寫過程中遇到的一部分問題。通過這些錯誤的調試,我學到了如何高效快速得調試程序并及時發(fā)現(xiàn)錯誤所在。通過調試發(fā)現(xiàn)斷點調試很重要,通過VC自帶的調試工具可以很快地找到錯誤。在進行斷點調試時可以觀察相關變量的值以發(fā)現(xiàn)錯誤所在。在程序調試過程中我只學到了一些最基本的方法。如何正確高效地實用調試工具還將在以后的工作學習中繼續(xù)學習。6 結論與展望本文所設計的Email分析系統(tǒng)能夠從Email服務器上接收到郵件,并通過關鍵字查找方式分析惡意Email,給用戶參考,最終是否刪除該Email由用戶決定,這樣做提高了系統(tǒng)的可靠性和安全性,不會誤刪用戶有用的Email。而且用戶可以根據(jù)自己的需要添加關鍵字,這樣為系統(tǒng)的可擴展性奠定了一個好的基礎。在進行郵件分組的時候,基于時間的分組方法及基于好友的分組方法。這兩種方法在優(yōu)缺點上進行了互補,給用戶對Email的管理帶來了極大的便利性。好友信息可以通過用戶自己添加。該系統(tǒng)能夠很好地實現(xiàn)分組及惡意Email的分析功能,并且具有很好的可擴展性,達到了預期的設計目標。從長遠的發(fā)展來看,本文所設計的系統(tǒng)還應加入一個學習機的功能,只有這樣Email分析系統(tǒng)才能夠更智能化,需要人工干預的程序比較少。Email分析系統(tǒng)的發(fā)展任重而道遠。前途一片光明,相信在不久的將來更智能化的Email分析系統(tǒng)會展現(xiàn)在我們的面前。參考文獻[1] [M].北京:電子工業(yè)出版社, 2005: 120133.[2] [M].北京:清華大學出版社, 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].天津:機械工業(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.致 謝本文是在徐明導師的幫助下完成的,在進行系統(tǒng)設計時同學和朋友也給予了我很大的幫助,特別是在我剛開始接觸編程的時候遇到了很多的問題,在同學和朋友的幫助下問題一一得到解決,再此特別感謝他們的幫助。 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