Outlook 自动将电子邮件从“已删除邮件”文件夹移动到其他文件夹

Outlook 自动将电子邮件从“已删除邮件”文件夹移动到其他文件夹,outlook,Outlook,我的公司使用云交换系统,当电子邮件在“已删除邮件”文件夹中保存30天时(我们使用Outlook 2010客户端),该系统会删除这些电子邮件。我想要一个脚本,将所有电子邮件从“已删除邮件”文件夹移动到第二个名为“垃圾”的文件夹。我能够在网上找到以下大部分脚本,但它对我不起作用,我不确定缺少/不正确的内容。感谢您的帮助 Sub MoveDeletedItems() Dim oSource As Outlook.MAPIFolder Dim oTarget As OutlookMAPIFolder D

我的公司使用云交换系统,当电子邮件在“已删除邮件”文件夹中保存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

首先,你有很多你不需要的东西

下面是一个示例,其中包含可以在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

首先,你有很多你不需要的东西

下面是一个示例,其中包含可以在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

我们不知道它是如何对你不起作用的,试着添加一些关于什么不起作用的相关信息。我很乐意添加更多信息。你在找什么?我试着运行上面的脚本,据我所知,什么都没有发生。也许我没有清楚地说明我的问题。我再试一次。我正在尝试使用一个VB脚本,该脚本在运行时使用Exchange帐户将电子邮件从Outlook 2010中的“已删除邮件”文件夹移动(而不是复制)到另一个文件夹。到目前为止,我有你在上面看到的脚本。当我运行VB脚本时,据我所知,什么也没有发生。不会从“已删除邮件”文件夹中移动任何电子邮件。我希望能得到帮助,了解VB脚本的人可以指出上面代码中的错误。我们不知道它是如何对您不起作用的,请尝试添加一些关于哪些不起作用的相关信息。我很乐意添加更多信息。你在找什么?我试着运行上面的脚本,据我所知,什么都没有发生。也许我没有清楚地说明我的问题。我再试一次。我正在尝试使用一个VB脚本,该脚本在运行时使用Exchange帐户将电子邮件从Outlook 2010中的“已删除邮件”文件夹移动(而不是复制)到另一个文件夹。到目前为止,我有你在上面看到的脚本。当我运行VB脚本时,据我所知,什么也没有发生。不会从“已删除邮件”文件夹中移动任何电子邮件。我希望有人能帮助我指出上面代码中的错误。谢谢你的时间和回答。非常感谢!Sorceri,谢谢你的时间和回答。非常感谢!