|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub MoveItems()
Dim Messages As Selection
Dim Msg As MailItem
Dim NS As NameSpace
Set NS = Application.GetNamespace("MAPI")
Set Messages = ActiveExplorer.Selection
If Messages.Count = 0 Then
Exit Sub
End If
For Each Msg In Messages
Select Case UCase(Msg.Subject)
Case Is ="Test subject"
Msg.Move n_folders("Outlook","收件匣","test")
End Select
Next
End Sub
Function n_folders(n_path As String)
Dim n_level As Integer
Dim i As Integer
n_level = Len(n_path) - Len(Replace(n_path, ",", ""))
ReDim n_pos(n_level)
i = 0
n_pos(0) = 0
n_folders = "NS"
For p = 1 To Len(n_path)
If Mid(n_path, p, 1) = "," Then
i = i + 1
n_pos(i) = p
End If
Next p
For i = 0 To n_level
If i = 0 Then
n_folders = n_folders & ".Folders('" & Mid(n_path, 1, n_pos(1) - 1) & "')"
End If
If i > 0 And i < n_level Then
n_folders = n_folders & ".Folders('" & Mid(n_path, n_pos(i) + 1, n_pos(i + 1) - n_pos(i) - 1) & "')"
End If
If i = n_level Then
n_folders = n_folders & ".Folders('" & Mid(n_path, n_pos(i) + 1, Len(n_path) - n_pos(i)) & "')"
End If
Next i
End Function |
|