【问题标题】:Accessing shared outlook inbox in python在 python 中访问共享的 Outlook 收件箱
【发布时间】:2015-08-31 03:56:55
【问题描述】:

我在 Outlook 中有一个共享收件箱,我想编写一些代码来获取来自共享收件箱的电子邮件。现在我可以从我的主收件箱中获取电子邮件,但我想为另一个收件箱做这件事。

这是目前为止的代码:

import os
import win32com.client

outlook = win32com.client.Dispatch('Outlook.Application').GetNamespace('MAPI')
inbox = outlook.GetDefaultFolder(6).Folders('Some Magic Folder')
messages = inbox.Items

我的猜测是我不应该查看 GetDefaultFolder 方法,而是查看其他方法,但我不太确定该查看哪里。

【问题讨论】:

    标签: python email outlook


    【解决方案1】:

    Namespace 类的GetSharedDefaultFolder 方法返回一个Folder 对象,该对象代表指定用户的指定默认文件夹。

    Sub ResolveName() 
      Dim myNamespace As Outlook.NameSpace 
      Dim myRecipient As Outlook.Recipient 
      Dim CalendarFolder As Outlook.Folder 
      Set myNamespace = Application.GetNamespace("MAPI") 
      Set myRecipient = myNamespace.CreateRecipient("Eugene Astafiev") 
      myRecipient.Resolve 
      If myRecipient.Resolved Then 
        Call ShowCalendar(myNamespace, myRecipient) 
      End If 
    End Sub 
    
    Sub ShowCalendar(myNamespace, myRecipient) 
      Dim CalendarFolder As Outlook.Folder 
      Set CalendarFolder = _ 
      myNamespace.GetSharedDefaultFolder _ 
      (myRecipient, olFolderCalendar) 
      CalendarFolder.Display 
    End Sub
    

    【讨论】:

    • inbox = outlook.GetSharedDefaultFolder(6) File "", line 3, in GetSharedDefaultFolder TypeError: The Python instance can not be convert to a COM object getting that error
    • 您是否将有效的收件人对象传递给 GetSharedDefaultFolder 方法?
    • 啊,我想我可能知道如何处理这个问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    • 2018-11-20
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 2017-10-03
    • 2019-01-26
    相关资源
    最近更新 更多