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