A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook Automation: is there a better way?



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8  
Old June 6th 08, 12:25 PM posted to microsoft.public.outlook.program_vba
deko
external usenet poster
 
Posts: 15
Default Outlook Automation: is there a better way?

Beta 2

does not error out, but the filter does not seem to work
note: messages exist in the Inbox that wd match filter criteria

? FindMessages()
562 unfiltered
@SQL="urn:schemas:httpmail:Subject" CI_PHRASEMATCH 'Flight'
0 filtered

Public Function FindMessages()
Const QT As String = """"
On Error GoTo HandleErr
Dim olapp As Outlook.Application
Dim olns As Outlook.NameSpace
Dim olfldr As Outlook.Folder
Dim olmi As Outlook.MailItem
Dim olitms As Outlook.Items
Dim matchedItems As Outlook.Items
Dim strFilter As String

Set olapp = New Outlook.Application
Set olns = olapp.GetNamespace("MAPI")
Set olfldr = olns.GetDefaultFolder(olFolderInbox)
Set olitms = olfldr.Items

'===== available fields ====='
'attachmentfilename
'httpmail -BCC
'httpmail -CC
'content-disposition-type
'content-media-type
'httpmail -Date
'datereceived
'httpmail -From
'HasAttachment
'htmldescription
'Importance
'normalizedsubject
'Priority
'httpmail-reply-to
'Sender
'Subject
'textdescription
'thread -topic
'to

'===== Keywords ====='
'CI_STARTSWITH
'CI_PHRASEMATCH

'strFilter = "@SQL=" & QT & "urn:schemas:httpmail:HasAttachment" & QT &
" = 1"
strFilter = "@SQL=" & QT & "urn:schemas:httpmail:Subject" & QT & "
CI_PHRASEMATCH 'Flight'"
Debug.Print olitms.Count & " unfiltered"
Debug.Print strFilter
Set matchedItems = olitms.Restrict(strFilter)
Debug.Print matchedItems.Count & " filtered"
Exit_He
On Error Resume Next
Set matchedItems = Nothing
Set olitms = Nothing
Set olfldr = Nothing
Set olns = Nothing
Set olapp = Nothing
Exit Function
HandleErr:
Debug.Print "Error Number " & Err.Number & ": " & Err.Description
Resume Exit_He
End Function

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Automation Automation Problem Out of Memory MikeA[_2_] Outlook and VBA 7 July 30th 07 02:31 PM
Problem with Outlook Automation Neil Outlook and VBA 13 January 15th 07 07:09 AM
Outlook Automation Tylendal Outlook and VBA 3 April 24th 06 02:39 PM
Outlook automation using vbs Marceepoo Outlook - Installation 1 January 17th 06 04:18 AM
Help on Outlook automation Neo Outlook - General Queries 1 January 15th 06 04:49 PM


All times are GMT +1. The time now is 02:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.