资源简介

用python+wxpython写的一个邮件收发客户端,原来一直用C++,最近一周学习了Python。这个小作品实现了邮件收发(能很好的解码pop3中文),账户管理(增加,删除,编辑,更换)。显示文件内容用了htmlwindow,对网页邮件也能够很好的显示。发送模块支持中文和附件,有问题的可以发邮件到jianger2005@sina.com或者csdn论坛给我发消息

资源截图

代码片段和文件信息

#-*- coding:utf_8 -*-
‘‘‘
Created on 2010-8-1

@author: aleac
‘‘‘
import poplib
import email
import email.header
import string
import base64   
import email.utils
import cPickle
import wx
class MyMail:
    def __init__(selfusr=““pass_=““server=““):
        self.address=““
        self.stmpaddr=““
        self.usr=usr
        self.pass_=pass_
        self.server=server
        self.zhengwen=““
        self.mailcount=0
        self.filename=““
        self.recvall=True
       
    def receiveAll(selfStatusBar):
        try:
            pop=poplib.POP3(self.server)
            pop.user(self.usr)
            pop.pass_(self.pass_)
            self.mailcountsize=pop.stat()
        except:
            return False
        mailfrom=[]
        mailtitle=[]
        mailobject=[]
        mailtime=[]
        maillist=[]
        for i in range(1self.mailcount+1):
            if self.server==“pop.sina.com“ or self.server==“pop.qq.com“:
                count=self.mailcount-i+1
            else:
                count=i
                
            message=pop.retr(count)[1]
            mail=email.message_from_string(string.join(message“\n“))
            maillist.append(mail)
            subject=email.Header.decode_header(mail[‘subject‘])[0][0]
            subcode=email.Header.decode_header(mail[‘subject‘])[0][1]
            if subcode==None:
                mailtitle.append(subject)
            else:
                mailtitle.append(unicode(subjectsubcode))
                
            mailfrom.append(email.utils.parseaddr(mail[“From“])[1])
            
            subject=email.Header.decode_header(mail[‘Date‘])[0][0]
            if subcode==None:
                mailtime.append(subject)
            else:
                mailtime.append(unicode(subjectsubcode))
                
            self.zhengwen=““
            if i>15:
                StatusBar.SetStatusText(“(“+str(i)+“/“+str(self.mailcount)+“) mails have been received in the background progress!“2)
            self.jiema(mail)
            mailobject.append(self.zhengwen)
            
        pop.quit()
        f=open(self.filename“w“)
        cPickle.dump(self.mailcount f)
        cPickle.dump(self.mailcount f)
        cPickle.dump(maillist f)
        cPickle.dump(mailfrom f)
        cPickle.dump(mailtitle f)
        cPickle.dump(mailobject f)
        cPickle.dump(mailtimef)
        f.close()
        #wx.MessageBox(“All received succeed!\nThe data is stored in “+self.filename+“.“)          
        return True
    def receiveTop(selfnum):
        try:
            pop=poplib.POP3(self.server)
            pop.user(self.usr)
            pop.pass_(self.pass_)
            self.mailcountsize=pop.stat()
        except:
            wx.MessageBox(“connect error!\nPlease make sure your computer has connected \nto the inernet or try in another time“)
        mailfrom=[]
        mailtitle=[]
        mail

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        376  2010-08-01 21:41  amail\.project

     文件        425  2010-08-01 21:41  amail\.pydevproject

     文件        186  2010-08-02 23:16  amail\.settings\org.eclipse.core.resources.prefs

     文件       1371  2010-08-01 12:58  amail\src\ad.html

     文件       6989  2010-08-07 00:07  amail\src\amail.py

     文件       5561  2010-08-07 00:07  amail\src\amail.pyc

     文件      16646  2010-08-07 01:05  amail\src\amailrun.py

     文件       2299  2010-08-03 13:10  amail\src\sendDlg.py

     文件       3158  2010-08-03 13:10  amail\src\sendDlg.pyc

     文件       3087  2010-08-03 12:09  amail\src\sendmail.py

     文件       4103  2010-08-03 12:34  amail\src\sendmail.pyc

     目录          0  2010-08-08 17:32  amail\.settings

     目录          0  2010-08-08 17:43  amail\src

     目录          0  2010-08-08 17:32  amail

----------- ---------  ---------- -----  ----

                44201                    14


评论

共有 条评论