Skip to Content
author's profile photo Former Member
Former Member

OLE - Search for a string in Outlook folders

Hi everyone,

I'm using the Application.AdvancedSearch objekt to search for a string in the Outlook folder "Inbox'.

I' having trouble passing the filter parameter. With a pair of Concatenate instructions I've built it up in order to pass it in the precise characters chain (see Microsoft reference for Application.AdvancedSearch Method :http://msdn.microsoft.com/en-us/library/bb219884.aspx)

I've already testet that it works without passing the filter parameter, or with an empty filter paramenter. Only by passing it it doesn't work any more, and I don't know if it depends on the passed string (which anyhow by debugging totally corresponds to the string in the microsoft reference).

It would be greatful if anyone has an idea about it.

Here my code: by the way, I testet with both of the Methods : 'ci_phrasematch' and 'like' , without success.

with 'ci_phrasematch':

lv_filter = 'Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " ci_phrasematch' .

concatenate lv_filter '''' into lv_filter SEPARATED BY space.

concatenate lv_filter 'Hallo' '''' '"' INTO lv_filter.

with 'like'

lv_filter = 'Chr(34) & "urn:schemas:httpmail:subject" & Chr(34) & " like' .

concatenate lv_filter '''' into lv_filter SEPARATED BY space.

concatenate lv_filter '%Hallo%' '''' '"' INTO lv_filter.

CALL METHOD OF OUT 'ADVANCEDSEARCH' = SEARCH EXPORTING #1 = 'Inbox' #2 = LV_FILTER ."#3 = 'True' #4 = 'MySearch'.

Thank you,

Christian

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Feb 11, 2011 at 02:40 PM

    Hi,

    Chr(34) in examples from Microsoft stands for ASCII 34 - double quote. You shouldn't concatenate it in ABAP literally.

    It works just fine:

    INCLUDE ole2incl.
    
    DATA outlook TYPE ole2_object.
    DATA search TYPE ole2_object.
    DATA results TYPE ole2_object.
    DATA count TYPE i.
    
    DATA filter TYPE string.
    DATA scope TYPE string.
    CREATE OBJECT outlook 'Outlook.Application'.
    
    check sy-subrc = 0.
    
    filter = '"urn:schemas:httpmail:subject" like ''%Test%'''.
    scope = '''Inbox'''.
    CALL METHOD OF
        outlook
        'AdvancedSearch' = search
      EXPORTING
        #1               = scope
        #2               = filter
        #3               = 'False'.
    check sy-subrc = 0.
    
    GET PROPERTY OF search 'Results' = results.
    check sy-subrc = 0.
    
    GET PROPERTY OF results 'Count' = count.
    check sy-subrc = 0.
    
    WRITE count.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      I am practically doing the same thing as you have shown here, but somehow the AdvancedSearch method is never called.

      I have tried with several possibilities like

      • With Filter,
      • Without Filter,
      • Getting Default folder name from Session.GetDefaultFolder( ).FolderPath
      • Using different folders etc.

      Do you think I am missing anything here?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.