简体   繁体   English

Outlook 发件人邮件问题

[英]Outlook Sender mail issue

I am trying to get an email body on basis of a particular sender name from the outlook inbox by using the win32.com client.我试图通过使用 win32.com 客户端从 outlook 收件箱中的特定发件人姓名获取 email 正文。 However, it only return the COMObject Restrict Here my code.但是,它只返回 COMObject Restrict Here my code。

import win32com.client as win32
import numpy as np


outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")

folder = outlook.GetDefaultFolder(6)
messagess = folder.Items

messages = messagess.Restrict("[SenderEmailAddress] = 'Vivek.Kumar@xxx.com'")
print(messages)
arr=[]
for m in messages:
    arr=m.Body
    print(arr)

The Items.Restrict method from the Outlook object model returns a new collection containing all of the items from the original that match the filter (an instance of the Items class) which is a COM object under the hood.来自 Outlook object model 的Items.Restrict方法返回一个新集合,其中包含原始集合中与过滤器( Items类的一个实例)匹配的所有项目,它是一个 COM object 在引擎盖下。 You may try to use methods and properties of the Items class in the code to make sure the result is valid.您可以尝试在代码中使用Items class 的方法和属性来确保结果有效。

You can read more about that method in the How To: Use Restrict method to retrieve Outlook mail items from a folder article.您可以在操作方法:使用 Restrict 方法从文件夹中检索 Outlook 邮件项目一文中阅读有关该方法的更多信息。

print() deals with scalar (string, integer, boolean, etc.) values. print()处理标量(字符串、integer、boolean 等)值。 It does not know anything about any particular COM object - the best it can do is output the object's type name ("COMObject").它不知道任何关于任何特定的 COM object - 它能做的最好的事情是 output 对象的类型名称(“COMObject”)。 There is no way it can know anything about the Items Outlook object. It is your responsibility to maker sense of it by actually looping through the collection and printing values that make sense in your particular case.它不可能知道关于Items Outlook object 的任何信息。您有责任通过实际循环遍历在您的特定情况下有意义的集合和打印值来理解它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM