Results 1 to 2 of 2
2002-03-10, 20:33 #1
- Join Date
- Aug 2001
- Spring City, Pennsylvania, USA
- Thanked 0 Times in 0 Posts
Outlook VBA Find Method Wierdness (Outlook 2K, No SP)
Stumped again and have to yell UNCLE! I am applying the FIND method to locate specific MailItems in the SENT ITEMS folder in Outlook. The FIND method happily locates the first MailItem I'm looking for based on the criterion:
FindStr = "[SenderName] = 'David Betts' "
Set MAIL_IM_LOOKING_FOR = itmSENT.Find(FindStr)
where itmSENT was defined as an ITEMS type of object. BUT, if I change the criterion to:
FindStr = "[Subject] = 'I KNOW This Subject is Here!' " or
FindStr = "[To] = 'I_KNOW_Who_I_Sent_This_Mail_To_Dammit!@DOMAIN.COM ' "
the FIND fails! I know the internal types of [To] and [Subject] exist... I can get to them if I use the GETFIRST, GETNEXT methods of locating the desired MailItem. Worse yet, all the FIND's above work FINE in *subfolders* of SENT ITEMS (assuming I go to the trouble of building one and transferring test MailItems into it, yadda, yadda). Anybody know what gives here?
Thanks in advance!
- David Betts
2002-03-11, 11:44 #2
- Join Date
- Dec 2000
- Burwash, East Sussex, United Kingdom
- Thanked 187 Times in 173 Posts
Re: Outlook VBA Find Method Wierdness (Outlook 2K, No SP)
For the [To] example, I think you need to enclose the address in another set of quotes (if you look in your sent items folder you'll probably see that the address already appears in a set of single quotes - those form part of the To field so you need to enclose them in another set!).
For the [Subject] one, I can't actually get this to work using a find, but you don't need to. You can just use:
Set MAIL_IM_LOOKING_FOR = itmsent("I KNOW This Subject is Here!")
Hope that helps.Regards,
Microsoft MVP - Excel