如果主题包含字符串,如何显示消息框
How to display msgbox if subject contains string
以下 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
是的。使用 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
,其他没有改变。
应该是
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
以下 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
是的。使用 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
,其他没有改变。
应该是
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