• Find Item In Outlook (VB6 – Automating Outlook)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Find Item In Outlook (VB6 – Automating Outlook)

    Author
    Topic
    #375199

    I’m trying to find an item in Outlook where the message body meets certain criteria. The item will be in a shared folder rather than the users default mailbox. I’ve got so far…

    Dim cOutlook As CEMail
    Dim cMailFolder As Outlook.MAPIFolder
    Dim olMailItem As Outlook.MailItem

    ‘// Create the outlook item to initialise outlook
    Set cOutlook = New CEMail

    ‘// Try and create a reference to the ‘Shared Marketing’ MAPI folder
    Set cMailFolder = cOutlook.OutlookNameSpace.Folders.Item(“Mailbox – Shared Marketing”)

    So once I’ve created my mail folder obect, I can use the ‘Find’ method to search that particular folder. The item I want to find would have a unique ID in the message body, say 44506. I’m stuck on the syntax to use to search the message body for this ID?

    ‘// Now start searching the folders for the selected campaign ID
    Set olMailItem = cMailFolder.Items.Find ????????

    Any Ideas??

    Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #609601

      I don’t think you canuse the Find method for this – others will correct me if I’m wrong. The Find method of an Items collection expects a Filter:


      Filter: Required String. An expression that will evaluate to True or False.

      The filter is a string expression containing one or more filter clauses joined by the logical operators And, Not and Or.

      A filter clause is a simple expression that evaluates to True or False; for example, [CompanyName] = “Microsoft”.

      Note that property names can be used in the expression and are identified and delimited by square brackets. Except for these bracketed property names, only literals are allowed within the expression

      • #609603

        Hans,

        I’ll be implementing your code as my search, I was hoping to do it in 1 line is all – lazy Monday morning coding…!!

        Thanks for your response.

    Viewing 0 reply threads
    Reply To: Find Item In Outlook (VB6 – Automating Outlook)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: