我遇到了一个问题。我有 Outlook,里面有一些包含消息的文件夹。我需要浏览所有这些文件夹,然后替换这些消息中的链接。可以这样做吗?
我使用 Kutools 分离了我的附件,现在我需要更改这些链接的路径。
我找到了很好的链接:
- 这可能就是我们检查电子邮件的方式: https://www.extendoffice.com/documents/outlook/5287-outlook-find-and-replace-subject.html
- 这可能是我们浏览所有文件的方法: https://stackoverflow.com/questions/45346183/excel-vba-looping-through-all-subfolders-in-outlook-email-to-find-an-email-with
我的代码不起作用,也许有人有解决方案或我可以阅读的链接。
我的代码:
Sub GetEmail()
Dim OutApp As Outlook.Application
Dim myNamespace As Outlook.Namespace
Dim Mfolder As Outlook.MAPIFolder
Dim Myitems As Outlook.Items
Dim myitem As Object
Dim Found As Boolean
Dim Folder As Outlook.MAPIFolder
Dim SubFolder As Outlook.MAPIFolder
Dim UserFolder As Outlook.MAPIFolder
Set OutApp = New Outlook.Application
Set Namespace = OutApp.GetNamespace("MAPI")
Set myInbox = myNamespace.GetDefaultFolder(olFolderInbox)
Set Myitems = myInbox.Items
On Error Resume Next
For Each Folder In Namespace.Folders
For Each SubFolder In Folder.Folders
For Each UserFolder In SubFolder.Folders
For Each myitem In Myitems
If myitem.Class = olMail Then
If InStr(1, myitem.Subject, "sketch") > 0 Then
Debug.Print "Found"
Found = True
'Debug.Print Folder.Name, "|", SubFolder.Name, "|", UserFolder.Name
End If
End If
Next myitem
Next UserFolder
Next SubFolder
Next Folder
On Error GoTo 0
End Sub