以下Outlook宏工作正常,但是,我希望仅当主题为MsgBox
或主题为LIKE 'Fees Due%'
时才显示此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
答案 0 :(得分: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
我添加了外If
... End If
,没有其他内容被更改。
答案 1 :(得分: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