Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Location
    Spring City, Pennsylvania, USA
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook VBA Find Method Wierdness (Outlook 2K, No SP)

    Hi Y'all,

    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

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Outlook VBA Find Method Wierdness (Outlook 2K, No SP)

    Hi David,
    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,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •