共享邮箱中的Outlook VBA访问文件夹 [英] Outlook VBA Access Folders in Shared Mailbox

查看:186
本文介绍了共享邮箱中的Outlook VBA访问文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Outlook中有一些VBA代码,其对主邮箱的表现非常理想-但是,当我添加辅助邮箱时,相同的代码仍然很麻烦-这是Outlook 2016.

I have some VBA code in Outlook which behaves perfectly for the main Mailbox - however the same code is struggling when I add a secondary mailbox - this is Outlook 2016.

阅读子文件夹似乎很麻烦-我可以读取信箱中的邮件,但不能阅读子文件夹.

It seems to be struggling with reading the sub folders - I can get it to read mail items in the Inbox, but not the sub folders.

代码:

Dim sharedemail As Outlook.Recipient
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder Outlook.MAPIFolder
Dim strSubject As String
Dim i As Integer

Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set sharedemail = myNameSpace.CreateRecipient("recip@domain.com")
Set myInbox = myNameSpace.GetSharedDefaultFolder(sharedemail, olFolderInbox)  

For itemCount = myInbox.items.Count To 1 Step -1 'Iterates from the end backwards

    Set item = myInbox.items(itemCount)
    strSubject = UCase(item.Subject)

    Select Case True

        Case InStr(strSubject, UCase("Holiday Request")) > 0
        'Set destination folder
        Set myDestFolder = myInbox.Folders("HolidayRequests")
        'move the email out of inbox
        item.Move myDestFolder

    End Select

Next

它停在Set myDestFolder行,因为它似乎无法选择该子文件夹-正如我说的那样,在主收件箱中,相同的代码似乎可以正常工作?

It stalls at the Set myDestFolder line as it can't seem to select that sub folder - as I say same code seems to work fine in main Inbox?

谢谢

推荐答案

请记住,Outlook在主OST文件中保留了共享的默认文件夹,并且它不同步子文件夹.

Keep in mind that Outlook keeps shared default folders in the primary OST file, and it does not sync the subfolders.

您可以
1.取消选中下载共享文件夹"复选框
2.使用扩展MAPI(C ++或Delphi)-这将相当复杂,因为您需要检索该邮箱的自动发现XML并适当地构造商店条目ID.
3.使用兑换-它是

You can either
1. Uncheck the "Download shared folders" checkbox
2. Use Extended MAPI (C++ or Delphi) - that would be fairly complex as you'd need to retrieve the autodiscover XML for that mailbox and construct the store entry id appropriately.
3. use Redemption - it s version of RDOSession.GetSharedDefaultFolder returns an online version of the folder (RDOFolder) with all its subfolders.

这篇关于共享邮箱中的Outlook VBA访问文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆