如何通过VBA代码按主题将电子邮件从Outlook传输到特定的文件夹?

我有2列在Excel中。 第一列是电子邮件的主题,第二列是具有特定主题的电子邮件必须移到的文件夹。 比如这两列:

Subject Folder A 1 B 2 C 3 

所以,当我得到一个主题为“A”的电子邮件,那么它必须移动到文件夹1.所以我的问题是我怎样才能使代码在Excel表中search邮件必须移动到哪个文件夹(我只需要这部分代码)。

我不能在网上find任何关于它的东西。

请参阅如何将每个电子邮件从收件箱移动到子文件夹的示例

现在循环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