想要把msg信件檔案的附件抓出來做處理,找到了這個Python 模組 msg-extractor
使用十分容易,但是這個模組是要在terminal裡執行,無法直接打在IDLE的編輯器上
所以稍微做了修改,使用 subprocess 模組來打指令就可以了
以下為程式碼 完整程式碼在我的 Github
#放置msg檔的檔案路徑 srcfilePath=os.path.join(‘C:\\‘, ‘Python2.7.10‘) #msg 檔名 fileName=‘123.msg‘ def MsgToExcelDatabase(srcfilePath,fileName): MailmsgPath=os.path.join(srcfilePath,fileName) #使用 subprocess執行打command的動作 #start extract attachment from 123.msg DIR = os.path.join(‘C:\\‘, ‘Python2.7.10‘, ‘msg-extractor-master‘, ‘ExtractMsg.py‘) subprocess.call([‘python‘, DIR, MailmsgPath]) #把路徑與檔名放入寫好的 def MsgToExcelDatabase(srcfilePath,fileName)
原文:http://www.cnblogs.com/vickychan222/p/4894122.html