Pra*_*dra 5 python outlook pywin32
我在 Outlook 中创建了一个规则,将所有传入邮件从特定发件人移动到我的收件箱中的子文件夹中。Like -
Inbox
- Subfolder
Run Code Online (Sandbox Code Playgroud)
我写了一段代码
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6) #6 = Inbox (without mails from the subfolder)
messages = inbox.Items
message = messages.GetLast()
body_content = message.body
print body_content #Sometimes has parsing error due to different encoding format
Run Code Online (Sandbox Code Playgroud)
我怎样才能
1)阅读收件箱内这个特定文件夹中的邮件
2) 处理像 UnicodeEncodeError: 'charmap' codec can't encode - character maps to
print (u'\2109') 也发出这个错误。
| 归档时间: |
|
| 查看次数: |
9025 次 |
| 最近记录: |