简体   繁体   中英

How to find two words in the subject line of email in vba?

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim strSubject As String
  strSubject = Item.Subject
     If (Trim(strSubject)) Like "FOR REVIEW*" Then
         Prompt$ = "Please do xyz"
       If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Review Subject Line") = vbNo Then
        Cancel = True
      End If
    End If
End Sub
  1. Need to find FOR REVIEW anywhere in the subject .

    note: * FOR REVIEW * doesn't works !!

  2. Need to change the button NO to 'Go back'. replacing No with Goback didn't work !!

try:

  "*" "FOR REVIEW" "*"

instead of

"FOR REVIEW*"

Changed

strSubject = Item.Subject
     If (Trim(strSubject)) Like "FOR REVIEW*" Then

To

Item.Subject LIKE "*For Review*"

So it finds the words.I removed TRIM function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM