【问题标题】:python outlook SetProperty() issue with underscore in string namespacepython Outlook SetProperty() 字符串命名空间中带有下划线的问题
【发布时间】:2021-06-24 11:47:57
【问题描述】:

对于我通过 python 使用 win32com 库自动发送的电子邮件,我需要在电子邮件标题属性中添加一些内容。代码是这样的:

olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "test mail"
newMail.BodyFormat = 2
newMail.HTMLBody = html_out
newMail.To = email_recipient
newMail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/%7B00020386-0000-0000-C000-000000000046%7D/_test_", 'xyz')

现在我遇到了 schemaName 中的下划线问题,因此它不会接受“_test_”。不知何故,我可以使用像 ...%7D/\_test_", 'xyz') 这样的反斜杠以 python 方式转义第一个下划线,如果我删除第二个下划线,它将起作用。但是对于第二个下划线,我还没有找到一个解决方案来逃避它,以便它被接受。

基本上 Outlook 应该能够处理这个问题,因为我从现有的电子邮件标题中读取了 _test_。

这里有什么线索吗?我找不到string namespace 的任何限制

【问题讨论】:

    标签: python automation outlook mapi


    【解决方案1】:

    Outlook 在处理 OOM 时会应用其业务逻辑并引入一些限制。作为一种解决方法,您可以尝试使用 Outlook 所基于的低级 API - Extended MAPI 或只是围绕该 API 的任何第三方包装器,例如 Redemption。您可以尝试使用MFCMAPI 手动处理属性名称。

    您也可以尝试在属性名称后附加任何有意义的符号。

    Custom HTTP headers : naming conventions 线程中描述了 Internet 标头命名约定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      • 2016-04-02
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 2019-04-25
      相关资源
      最近更新 更多