Extracting certain emails (subject)

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
 
M

Michael Bauer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top