Remove signature if body contains string

The end goal is to remvoe my signature if a certain line is in the body. For now, I can check the body with the following.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    If TypeName(Item) <> "MailItem" Then Exit Sub

       If Item.Body like "*something*" Then
        MsgBox "it working"
       End If

End Sub

      

Everything is good and from head to head I thought I could use

 Item.Signature.Remove

      

Just to find out that the signature is not Property. My cig also contains an image (comp logo). I have searched and I seem to see that the signature itself is part of the Body. Do I need to replace the body with some function TRIM

plus remove the image? Not sure where to go or if there is an easier way.

+3


source to share


1 answer


For those who may find this helpful. The signature is part of the property Body

. I know my signature starts with my name, so I used a function Instr

to get the starting position and go from there.



Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

If TypeName(Item) <> "MailItem" Then Exit Sub
    If Item.Body Like "*MyCatchPhrase*" Then
      midcount = InStr(Item.Body, "MyFull Name")
      FinNum = midcount - 1
      Item.Body = Left(Item.Body, FinNum)
    End If

End Sub

      

+3


source







All Articles