1

我们公司正在使用 Enterprise Vault 系统来存储归档的电子邮件。10% 的时间我能够检索到我的电子邮件。所以我正在切换以将它们存储在我的计算机上。

这是我要做的:

  1. 计算“存档”文件夹中的电子邮件数量
  2. 在“存档”文件夹中打开 n 个电子邮件项目
  3. 复制 n 个电子邮件项目
  4. 将 n 电子邮件项目移动到“计算机”文件夹(注意:电子邮件必须打开并移动。
  5. 关闭电子邮件窗口
  6. 重复直到 n = x

我的电脑上有一个 .pst 文件夹。

有人可以帮我开发最简单的代码来完成第 2 步吗?

这是我目前所拥有的......

Sub MoveToFolder()

Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olArcFolder As Outlook.MAPIFolder
Dim olCompFolder As Outlook.MAPIFolder
Dim mailboxNameString As String
Dim myInspectors As Outlook.MailItem
Dim myCopiedInspectors As Outlook.MailItem
Dim x As Integer
Dim iCount As Integer

mailboxNameString = "Emails Stored on Computer"
Set olNameSpace = olApp.GetNamespace("MAPI")
Set olArcFolder = olNameSpace.Folders(mailboxNameString).Folders("Archived")
Set olCompFolder = olNameSpace.Folders(mailboxNameString).Folders("Computer")

'Make some kind of loop that counts the emails in the folder "Computer"
'opens it up, and then moves it to the folder "Archived"
Set myInspectors = Outlook.Application.ActiveInspector.CurrentItem
Set myCopiedInspectors = myInspectors.copy
myCopiedInspectors.Move (olCompFolder)
'next email
4

1 回答 1

2

好吧,伙计们,我想我毕竟是在自学。这适用于我想要的。

Sub MoveToFolder()

Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olArcFolder As Outlook.MAPIFolder
Dim olCompFolder As Outlook.MAPIFolder
Dim mailboxNameString As String
Dim myInspectors As Outlook.MailItem
Dim myCopiedInspectors As Outlook.MailItem
Dim myItem As Outlook.MailItem
Dim M As Integer
Dim iCount As Integer

Set olNameSpace = olApp.GetNamespace("MAPI")
Set olArcFolder = olNameSpace.Folders("Emails Stored on Computer").Folders("Archived")
Set olCompFolder = olNameSpace.Folders("Emails Stored on Computer").Folders("Computer")


For M = 1 To olArcFolder.items.Count
    Set myItem = olArcFolder.items(M)
    myItem.Display
    Set myInspectors = Outlook.Application.ActiveInspector.CurrentItem
    Set myCopiedInspectors = myInspectors.copy
    myCopiedInspectors.Move olCompFolder
    myInspectors.Close olDiscard
Next M



End Sub
于 2013-06-20T21:16:45.470 回答