More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 24-May-2018 19:54

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 ]  
 Basic Outlook Printer Friendly Version
Working with Outlook items, folders, recipients; dealing with security; writing event handlers
Find Text
I am trying to search (find) string in the email body at the send time I tried many times but no success. below is one of my trying:

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

If Item.Body.Find("Something I am looking for") Is Nothing Then
Call MsgBox("It is not there", vbOKOnly, "Close Me")

End If

End Sub

But find method is not working or gives me my needs.

Anyone can help?

  27-Jul-2010  12:02
  27-Jul-2010  12:17   
I tried this as well, no luck.

If InStr(Item.Body, "SomeThing") Is Nothing Then
Exit Sub
Call MsgBox("Fine", vbOKOnly, "Fine")
End If
  27-Jul-2010  12:27   
This is the problem expression:

    InStr(Item.Body, "SomeThing") Is Nothing

Instr() returns an integer representing the position of the next, not an object. This expression will return True if the text is not found, False if it is found:

    InStr(Item.Body, "SomeThing") = 0

Remember that you can look up functions like Instr() in VBA Help if they don't appear to be working as expected. Simply put the cursor on the function name in your code and press F1.
  27-Jul-2010  14:41   
Some People were found to make our life easier.

Thanks a lot.
    Page [ 1 ]