[英]How to count emails, according to criterion, from all folders and subfolders in Outlook using Excel VBA?
[英]How can I transport emails from outlook to specific folders by topic with a VBA code?
我在Excel中有2列。 第一列是电子邮件的主题,第二列是具有特定主题的电子邮件必须移动到的文件夹。 例如两列:
Subject Folder
A 1
B 2
C 3
因此,当我收到主题为“A”的电子邮件时,它必须移动到文件夹1.所以我的问题是如何制作代码以在Excel工作表中搜索邮件必须移动到哪个文件夹(我只需要这个部分代码)。
我无法在互联网上了解任何事情。
请参阅有关如何将每封电子邮件从收件箱移动到子文件夹的示例
现在循环遍历2列,请参见下面的示例
Dim ItemSubject As String
Dim SubFldr As String
i = 2 ' i = Row 2
With Worksheets("Sheet1") ' Sheet Name
Do Until IsEmpty(.Cells(i, 1))
ItemSubject = .Cells(i, 1).Value '(i, 1) = (Row2,Column1) = A2 Value = Subject
SubFldr = .Cells(i, 2).Value '(i, 2) = (Row 2, Column 2) = B2 Value = FolderName
'// Loop through Inbox Items backwards
For lngCount = Items.Count To 1 Step -1
Set Item = Items.Item(lngCount)
If Item.Subject = ItemSubject Then ' if Subject found then
Set SubFolder = Inbox.Folders(SubFldr) ' Set SubFolder
Item.Move SubFolder ' Move to SubFldr
End If
End If
Next ' exit loop
i = i + 1 ' = Row 2 + 1 = Row 3
Loop ' now loop on Row 3
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.