2017-08-22 3 views
0

次のOutlookマクロは完全に機能しますが、または件名がLIKE' Status Change%'の場合にのみMsgBoxが表示されます。これは可能ですか?件名に文字列が含まれている場合msgboxを表示する方法

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

はあなたを

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 
+1

パーフェクト!まさに私が探していたもの。お手数をおかけしていただきありがとうございます。これは多くの頭痛から私を救ってくれました。 – Tennis

1

はい。

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を追加しました:Like演算子を使用します。

+0

感謝するべきです。はい、これは実際に動作します。 – Tennis

関連する問題