昨天我可以使用 win32client 读取 msg 文件,但是今天突然它抛出了一个错误,而我正在对同一个文件运行相同的代码。
找不到原因。关于错误信息没有太多解释。昨天网络中断,后来恢复了,但似乎不是原因。
import win32com.client as win32
outlook = win32.Dispatch('Outlook.Application').GetNameSpace('MAPI')
msg = outlook.OpenSharedItem('path/file.msg')
print(msg.SenderName)
昨天运行时,输出显然是一个名称,例如 Joe Doe,但今天它是粘贴在下面的错误消息。
com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', "We can't open 'RE Your Sumo Invoice - Gas.msg'. It's possible the file is already open, or you don't have permission to open it.\n\nTo check your permissions, right-click the file folder, then click Properties.", None, 0, -2147287038), None)