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
  #6  
Old June 6th 08, 06:17 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Outlook Automation: is there a better way?

Correct, PST is not subject to this limitation.
There is no way to clear the cache.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"deko" wrote in message
...
Thanks for the heads up, Dmitry.

I'm wondering if there's a way to force the cache to clear itself. Also,
I assume on a local Outlook PST there are no cache issues.

From reading the MSDN article, the Restrict method seems to the better
option for my needs: "The Restrict method is significantly faster if there
is a large number of items in the collection, especially if only a few
items in a large collection are expected to be found." This is the case
when searching a large Inbox for messages matching one or two email
addresses.

What's really interesting is the ability to use an SQL query as the
filter:

The example in the MSDN article is this:
filter = /mapi/proptag/0x0037001f"" =
'the right ""stuff""'"

What is that hyperlink? Is that just part of the example in the MSDN
article?

How about: "@SQL = "SELECT EmailAddress from tblContactEmailAddresses" -
would this work as a Restrict filter?


"Dmitry Streblechenko" wrote in message
...
Don't use Restrict unless the restriction stays the same: Exchange caches
restrictions for a week by default. Cached restriction arae updated every
time an item in the folder iss modified/added/deleted.
Unless you really want the restriction to be cached, do not use Restrict
against an Exchange store.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"JP" wrote in message
...
In addition to what Dmitry suggested, you could also use the Restrict
Method to limit you search to ONLY those items in the Inbox that match
your criteria. This would significantly reduce the amount of time
spent looping through a folder.

See
http://msdn.microsoft.com/en-us/library/bb220369.aspx


--JP

On Jun 5, 6:33 pm, "deko" wrote:
I just upgraded to Office 2007 and would like to refactor my automation
code
to improve speed and perhaps add some new functionality.

My Access 2007 database has code that searches Outlook 2007 for email
messages. The database contains Contacts, each with one or more email
addresses. The current code loops through each message in the Outlook
Inbox
trying to match one of the Contact's email addresses with the
SenderEmailAddress property of each mail item. When a match is found,
the
message subject and other data is added to a recordset and displayed in
a
datasheet in Access.

Here's an abbreviated example:

Dim olapp As Outlook.Application
Dim olmi as Outlook.MailItem
Dim olitms as Outlook.Items
Dim objItem As Object

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

Do While Not rstContactAddresses.EOF
For Each objItem in olitms
If TypeOf objItem Is Outlook.MailItem Then
Set olmi = objItem
If olmi.SenderAddress = rstContactAddresses!EmailAddress
Then
Call AddToRecordset(olmi.whatever)
End if
End if
Next objItem
Loop

Is there a better way to do this with VBA? Is it worth trying to use
C# and
VSTO here? Is it possible to tap into the indexed Outlook email search
feature? Other new stuff in 2007 that can help?

Thanks in advance.






 




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 05:20 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.