0

以下 Outlook 宏可以完美运行,但是,我希望MsgBox仅在 Subject 为LIKE 'Fees Due%'OR Subject is时出现LIKE' Status Change%'。这可能吗?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If MsgBox("Do you want to continue sending the mail?", vbOKCancel) <> vbOK Then
        Cancel = True
    End If
End Sub
4

2 回答 2

1

是的。使用Like运算符:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Subject Like "Fees Due*" Or Item.Subject Like "Status Change*" Then
        If MsgBox("Do you want to continue sending the mail?", vbOKCancel) <> vbOK Then
            Cancel = True
        End If
    End If
End Sub

我添加了 external If... End If,没有其他任何改变。

于 2017-08-22T20:21:50.560 回答
0

应该

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim Subject As String
    Subject = Item.Subject

    If Subject Like "*Fees Due*" Or Subject Like "*Status Change*" Then
        If MsgBox("Do you want to continue sending the mail?", _
                   vbYesNo + vbQuestion + vbMsgBoxSetForeground, _
                                               "Check Subject") = vbNo Then
            Cancel = True
        End If

    End If
End Sub
于 2017-08-22T20:22:01.447 回答