Skip to content

Instantly share code, notes, and snippets.

@fo40225
Created July 4, 2016 15:38
Show Gist options
  • Save fo40225/c00a65da2584bff78bbdc1f78022f52f to your computer and use it in GitHub Desktop.
Save fo40225/c00a65da2584bff78bbdc1f78022f52f to your computer and use it in GitHub Desktop.
Sub MoveMail()
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
ns = Application.GetNamespace("MAPI")
moveToFolder = ns.Folders("資料檔名稱").Folders("資料夾名稱")
For Each objItem In Application.ActiveExplorer.Selection
If moveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move(moveToFolder)
End If
End If
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment