1

我的公司使用云 Exchange 系统,当电子邮件在“已删除邮件”文件夹中 30 天后删除(我们使用 Outlook 2010 客户端)。我想要一个脚本,将所有电子邮件从“已删除邮件”文件夹移动到名为“垃圾箱”的第二个文件夹。我能够在线找到以下大部分脚本,但它对我不起作用,我不确定缺少/不正确的内容。任何帮助表示赞赏...

Sub MoveDeletedItems()
Dim oSource As Outlook.MAPIFolder
Dim oTarget As OutlookMAPIFolder
Dim oDummy As Object
Dim oToMove As Object
Dim colItems As Outlook.Items
Dim i As Long

Set oSource = Application.Session.GetDefaultFolder(olFolderDeletedItems)
Set oTarget = oSource.Folders.Folder("Trash")

Set colItems = oSource.Items

For i = colItems.Count To 1 Step -1
Set oToMove = colItems(i)
Set oDummy = oToMove.Move(oTarget)
Next
End Sub
4

1 回答 1

1

拳头你有很多你不需要的东西

这是一个可以在 Outlook 中作为宏运行的注释示例。

Sub MoveDeletedItems()
'setup some error checking
On Error GoTo err_rpt
Dim oSource As Outlook.MAPIFolder
Dim oTarget As Outlook.MAPIFolder
Dim oItem

'get the deleted Items folder
Set oSource = Application.Session.GetDefaultFolder(olFolderDeletedItems)
'get the folder under the Deleted Items folder called Trash
Set oTarget = oSource.Folders("Trash")
'loop through all the items in the source folder
For Each oMailItem In oSource.Items 
    'move the item to the target folder
    oItem.Move oTarget
Next

err_rpt:
If Err.Number > 0 Then
    MsgBox Err.Description
End If
'release the folders
Set oTarget = Nothing
Set oSource = Nothing
End Sub
于 2013-10-24T04:28:36.010 回答