VSTO Outlook:找不到共享收件箱的子文件夹 [英] VSTO Outlook: Cannot find subfolders of shared inbox

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

问题描述

我正在尝试将邮件从任何文件夹移动到共享收件箱的特定子文件夹中.在尝试了许多无法使用的不同操作之后,我尝试遍历收件箱中的每个文件夹,并检查该文件夹是否具有我要查找的名称.当我尝试移动mailitem时,收到消息,提示该元素无法移动.在搜寻了更长的时间以寻找原因之后,我的收件箱中显然没有文件夹存在,并且对于每个循环而言,如果不检查单个条目就退出该文件夹.那么我应该如何访问仅知道其名称的特定子文件夹?

I am trying to move mails from any folder to a very specific subfolder of a shared inbox. After trying many different things that did not work I tried to loop through every single folder in the inbox und check if it has the name I am looking for. When I try moving the mailitem, I get the message that the element could not be moved. After searching a little bit longer for the cause I found out, that apparently no folder inside of my inbox exist and the for each loop exits without checking a single entry. So how am I supposed to access a specific subfolder which i only know the name of?

相关代码:

Private Const destFolder = "myfoldername"

Public Function MoveMail()
    SelectedItems = Globals.ThisAddIn.Application.ActiveExplorer.Selection
    For Each Item In SelectedItems
        Call MoveSelectedMail(Item)
    Next Item
End Function

Function MoveSelectedMail(Item As Outlook.MailItem)
    Item.Move(GetFolderToMove(destFolder))
End Function

Function GetFolderToMove(ByVal FolderName As String) As Outlook.Folder
    Dim NS As Outlook.NameSpace
    Dim objOwner As Outlook.Recipient
    NS = Globals.ThisAddIn.Application.GetNamespace("MAPI")
    objOwner = NS.CreateRecipient("NameofSharedMailbox")
    objOwner.Resolve()

    If objOwner.Resolved Then
        Dim inbox As Outlook.Folder
        inbox = NS.GetSharedDefaultFolder(objOwner, OlDefaultFolders.olFolderInbox)
        For Each folder As Outlook.Folder In inbox.Folders
            MsgBox(folder.Name)
            If folder.Name = FolderName Then
                Return folder
            End If
        Next folder
    End If
End Function

这是我在VBA中使用的代码,但是当我开始尝试做与VSTO插件相同的操作时却没用:

This is the code I used in VBA but did not work when I started trying to do the same thing as VSTO addin:

Function GetFolderToMove(ByVal FolderPath As String) As Outlook.Folder
    Dim NS As Outlook.NameSpace
    Dim objOwner As Outlook.Recipient
    Set NS = Application.GetNamespace("MAPI")
    Set objOwner = NS.CreateRecipient("NameofSharedMailbox")
    objOwner.Resolve

    If objOwner.Resolved Then
        Set GetFolderPath = NS.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders(destFolder)
    End If
End Function

我尝试过但没有帮助我解决此问题的内容:

What I tried but did not help me solve this problem:

  • 尝试仅返回共享收件箱,但此方法有效,但是,该收件箱不是我要将邮件移至的文件夹.

简而言之:我正在尝试将邮件移至共享收件箱的子文件夹,但是根据错误消息,似乎没有子文件夹.

In short: I am trying to move a mail to a subfolder of a shared inbox but there seem to be no subfolders according to the error messages.

希望您能帮助我.

修改: 我的问题可能有点不合适,因为我的Outlook帐户所拥有的权限似乎有问题.如果要通过这种方式解决问题,我将更新此线程并关闭ist.

My Problem might be a little bit out of place as it seems that there might be a problem with the permissions my outlook account has. If the problem is going to be resolved that way, I will update this thread and close ist.

推荐答案

我解决了它-我不确定这到底是怎么发生的,但肯定与我拥有的权限有关.

I solved it - I am not entirely sure how exactly this could have happened but it certainly had to do with the permissions I had.

这篇关于VSTO Outlook:找不到共享收件箱的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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