現在,我有一些代碼執行以下操作獲取附件的哈希.msg文件
- 獲取從收件箱中的郵件
- 下載電子郵件
- 經過每一個被下載的電子郵件,並提取附件
- 保存附件
- 獲取所保存的文件的哈希
但不是保存附件,是否有可能只獲取附件的散列並跳過保存?
attachments = message.Attachments
for attachment in attachments:
if attachment.FileName.endswith(".msg"):
attachment.SaveASFile(
os.path.dirname(os.path.abspath(__file__)) + '/attachments/' + str(
time.time()) + "-" + message.subject + "-" + attachment.FileName)
編輯:
這是我已經試過:
def get_attachments(message):
attachments = message.Attachments
for attachment in attachments:
data_array = message.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37010102")
print len(data_array)
這是我得到的錯誤:
pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, u'Microsoft Outlook', u'The property "http://schemas.microsoft.com/mapi/proptag/0x37010102" is unknown or cannot be found.', None, 0, -2147221233), None)
Process finished with exit code 1
嗯,我得到一個奇怪的錯誤,這將編輯我的問題,以反映我的反饋。 –
你在PC上安裝了哪些Outlook版本?事實是,PropertyAccessor不允許在舊的Outlook版本中獲得巨大的值。您需要使用低級別的API - 擴展MAPI或圍繞該API的任何其他包裝器(例如Redemption)。 –
您是否在獲取PR_ATTACH_DATA_BIN屬性值之前簽出Type屬性? –