1

私の会社では、削除済みアイテム フォルダーに 30 日間保存されたメールを削除するクラウド Exchange システムを使用しています (Outlook 2010 クライアントを使用しています)。すべての電子メールを [削除済みアイテム] フォルダーから "Trash" という 2 番目のフォルダーに移動するスクリプトが必要です。次のスクリプトのほとんどをオンラインで見つけることができましたが、うまく機能せず、何が欠けているか、間違っているかわかりません。どんな助けでも大歓迎です...

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 に答える