在 python 中访问共享 Outlook 收件箱
Accessing shared outlook inbox in python
我在 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 方法,而是查看其他方法,但我不太确定该查看何处。
命名空间的 GetSharedDefaultFolder 方法 class returns 表示指定用户的指定默认文件夹的 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
我在 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 方法,而是查看其他方法,但我不太确定该查看何处。
命名空间的 GetSharedDefaultFolder 方法 class returns 表示指定用户的指定默认文件夹的 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