简体   繁体   English

VB.net Outlook获取自定义文件夹邮件

[英]VB.net Outlook get custom folder mail

Hey all i am using this code here: 嘿,我在这里使用这段代码:

Dim tempInbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim newMail As Outlook.MailItem
Dim customFolder As String = "Mainbox - testing here"

tempApp = CreateObject("Outlook.Application")
tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Parent.Folders(customFolder)
InboxItems = tempInbox.Items

For Each newMail In InboxItems
 ......

In order to grab that users email that i have. 为了抓住那个用户,我有电子邮件。 Problem is that the name of the folder Mainbox - testing here was not found (The operation failed. An object could not be found.) and errors on this line: 问题是文件夹Mainbox的名称-找不到测试 (操作失败。找不到对象。),并在此行出现错误:

tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Parent.Folders(customFolder)

If i use a folder within my email box: 如果我在电子邮件框中使用文件夹:

Mainbox - My Name Here
  A Folder 1
  A Folder 2

it works just fine using the code above... 使用上面的代码就可以了...

What would i be missing in order to find this custom folder? 为了找到此自定义文件夹,我会缺少什么?

The folder structor looks like this: 文件夹构造函数如下所示:

Mainbox - My Name Here
  A Folder 1
  A Folder 2
Archive Folders
  Deleted Items
  Send Items
Mainbox - testing here
  Inbox
Vault - My Name Here
  A Folder 1
  A Folder 2

Your code assumes that folder is on the same level as the Inbox. 您的代码假定该文件夹与“收件箱”处于同一级别。

Use Namespace.Folders.Item(customFolder) 使用Namespace.Folders.Item(customFolder)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM