Extracting certain emails (subject)

  • Thread starter Thread starter Animal
  • Start date Start date
A

Animal

Hi:

I have a bit of code that I am running directly in AC2003 to import emails
from oulook. Everything works perfectly except that I can not get emails
meeting a certain criteria. I need all emails that start with ABC* (see
code below). I have tried lots of different possibilities but all fail. I
would really appreciate any help here.

....
If OlMail.UnRead = True Then
OlMail.UnRead = False 'Mark mail as read
Rst.AddNew
Rst!Name = OlMail.SenderName
If InStr(1, OlMail.Subject, "ABC*") > 0 Then
....

Thanks
 
meeting a certain criteria. I need all emails that start with ABC*

Do you really mean: start with ABC*? Then your code is correct. The
function compares case-sensitive by default (vbBinaryCompare) and
case-insensitive with the vbTextCompare-parameter.

If you want to say: start with ABC (and maybe followed by any
characters) then please write exactly that, without the *-character.

Case-sensitive: If InStr(1, OlMail.Subject, "ABC") > 0 Then

Case-insensitive: If InStr(1, OlMail.Subject, "ABC", vbTextCompare) > 0
Then
 
Back
Top