根据附件名称分类的电子邮件

时间:2019-05-13 15:51:14

标签: categories outlook-vba email-attachments

我希望在运行宏时对包含具有特定名称的附件的电子邮件进行分类

根据之前的讨论,我认为代码的一部分将是

ElesIf InStr(1, olItem.Attachments(0).DisplayName, "example", vbTextCompare) > 0 Then olItem.Categories = "CAT1"

我希望将其包含在当前宏中:

Public Sub autocategories()
    Dim olItem As Object
    For Each olItem In Application.ActiveExplorer.Selection
        If InStr(1, olItem.Subject, "=SUB1=", vbTextCompare) > 0 Then
            olItem.Categories = "SUB1"
        ElseIf InStr(1, olItem.Subject, "=SUB2=", vbTextCompare) > 0 Then
            olItem.Categories = "SUB2"
        ElseIf InStr(1, olItem.Sender, "SEN1", vbTextCompare) > 0 Then
            olItem.Categories = "SEN1"
        ElseIf InStr(1, olItem.Sender, "SEN2", vbTextCompare) > 0 Then
            olItem.Categories = "SEN2"
        ElseIf InStr(1, olItem.Body, "BOD1", vbTextCompare) > 0 Then
            olItem.Categories = "BOD1"
        ElseIf InStr(1, olItem.Body, "BOD2", vbTextCompare) > 0 Then
            olItem.Categories = "BOD2"
        End If
        olItem.Save
    Next olItem
    Set olItem = Nothing
End Sub

目的是改善我们分配每天收到的电子邮件的方式。

0 个答案:

没有答案