|
用Outlook 2010处理邮件归档至指定文件夹,由于文件夹的数量很多(大概200多个),归档时要到处找文件夹,效率很低。
在网上找了两个outlook vbs 稍微修改了一下直接拿来用。
现在大部分时候可以正常使用这个功能,但不知道为什么有时会把Outlook弄假死了,只能重启Outlook。
请大家帮手看看代码是不是有什么Bug之类的问题帮手完善一下,谢谢各位!!!!!
================================
- '查找Outlook中指定的文件夹 (支持通配符"*" / "&") , 并移动邮件至该文件夹
- Private m_Folder As Outlook.MAPIFolder
- Private m_Find As String
- Private m_Wildcard As Boolean
- Public Sub FindFolder()
- Dim Name$
- Dim Folders As Outlook.Folders
- Dim objNS As Outlook.NameSpace
- Dim MyFolder As Outlook.MAPIFolder
- Dim objItem As Outlook.MailItem
- Dim ctr As Integer
- Set m_Folder = Nothing
- m_Find = ""
- m_Wildcard = False
- Name = InputBox("Find Name:", "Search Folder", "**")
- If Len(Trim$(Name)) = 0 Then Exit Sub
- m_Find = Name
- m_Find = LCase$(m_Find)
- m_Find = Replace(m_Find, "%", "*")
- m_Wildcard = (InStr(m_Find, "*"))
- Set Folders = Application.Session.Folders
- LoopFolders Folders
- If Not m_Folder Is Nothing Then
- If MsgBox("Activate Folder: " & vbCrLf & m_Folder.FolderPath, vbQuestion Or vbYesNo) = vbYes Then
- On Error Resume Next
- ctr = 0
- Set MyFolder = m_Folder
- For Each objItem In Application.ActiveExplorer.Selection
- If MyFolder.DefaultItemType = olMailItem Then
- If objItem.Class = olMail Then
- ctr = ctr + 1
- objItem.Move MyFolder
- End If
- End If
- Next
- Set objNS = Nothing
- Set MyFolder = Nothing
- End If
- Else
- MsgBox "Not Found", vbInformation
- End If
- End Sub
- '查找文件夹
- Private Sub LoopFolders(Folders As Outlook.Folders)
- Dim F As Outlook.MAPIFolder
- Dim Found As Boolean
- For Each F In Folders
-
- If m_Wildcard Then
- Found = (LCase$(F.Name) Like m_Find)
- Else
- Found = (LCase$(F.Name) = m_Find)
- End If
- If Found Then
- Set m_Folder = F
- Exit For
- Else
- LoopFolders F.Folders
- If Not m_Folder Is Nothing Then Exit For
- End If
-
- Next
-
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|