Discussion:
Accessing Outlook "Search Folders"
(too old to reply)
Ken Slovak - [MVP - Outlook]
2009-09-29 20:02:31 UTC
Permalink
Outlook version?

In Outlook 2007 you'd use NameSpace.DefaultStore.GetSearchFolders() to get
the Folders collection of search folders. From there you can get the one of
interest.

In Outlook 2003 or earlier you'd need to be using a different API such as
Redemption (www.dimastr.com).
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
I was given the task of pulling all of the sent and received items for
a user for the previous day and writing it to an Excel folder. Task
Completed!
I tested this on my Inbox, but my boss wants me to run it on a
subfolder located in his "Search Folders". Apparently Outlook does
not recognize "Search Folders" as a mailbox folder.
So my question is, how can I access this folder?
McKilty
2009-09-29 19:59:02 UTC
Permalink
My Code:

Dim iMailItem As Integer
Dim dteStart As String
Dim dteEnd As String

Dim myOutlook As Outlook.Application
Dim myNameSpace As Namespace
Dim mItemCollection As Items
Dim myMailItem As MailItem

Dim SafeMail

Dim sUser As String
Dim sMailbox As String
Dim sFolder As String
Dim sSaveLocation As String

On Error GoTo ErrorHandler

'U S E R V A R I A B L E S
sUser = "Fname"
sMailbox = "Mailbox - LName, FName"
sFolder = "outlook:Search Folders\Current Sent & Received\"

dteStart = (Date - 1 & " 00:00")
dteEnd = (Date - 1 & " 23:59")

Set myOutlook = CreateObject("Outlook.Application")
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set mItemCollection = myNameSpace.Folders(sMailbox).Folders("Search
Folders").Folders("Current Sent & Received") 'FAILS ON THIS LINE

'Set Filter to previous day
Set mItemCollection = mItemCollection.Restrict("[SentOn] >= '" &
dteStart & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] <= '" &
dteEnd & "'")

mItemCollection.Sort "[SentOn]", False

ETC
Dmitry Streblechenko
2009-09-29 20:44:44 UTC
Permalink
See http://www.dimastr.com/redemption/rdo/rdosearches.htm
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"McKilty" <***@gmail.com> wrote in message news:7a425929-5cec-4f31-bc62-***@d10g2000yqh.googlegroups.com...
On Sep 29, 4:02 pm, "Ken Slovak - [MVP - Outlook]"
Post by Ken Slovak - [MVP - Outlook]
Outlook version?
In Outlook 2007 you'd use NameSpace.DefaultStore.GetSearchFolders() to get
the Folders collection of search folders. From there you can get the one of
interest.
In Outlook 2003 or earlier you'd need to be using a different API such as
Redemption (www.dimastr.com).
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment
Options.http://www.slovaktech.com/products.htm
I was given the task of pulling all of the sent and received items for
a user for the previous day and writing it to an Excel folder. Task
Completed!
I tested this on my Inbox, but my boss wants me to run it on a
subfolder located in his "Search Folders". Apparently Outlook does
not recognize "Search Folders" as a mailbox folder.
So my question is, how can I access this folder?
Thanks Ken.

Unfortunately, Outlook 2003. We do have and use Redemption, so I'm
hoping I can find an example on his site because I'm not sure I can
figure put how to write this.
McKilty
2009-09-29 21:01:35 UTC
Permalink
Seehttp://www.dimastr.com/redemption/rdo/rdosearches.htm
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
On Sep 29, 4:02 pm, "Ken Slovak - [MVP - Outlook]"
Post by Ken Slovak - [MVP - Outlook]
Outlook version?
In Outlook 2007 you'd use NameSpace.DefaultStore.GetSearchFolders() to get
the Folders collection of search folders. From there you can get the one of
interest.
In Outlook 2003 or earlier you'd need to be using a different API such as
Redemption (www.dimastr.com).
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment
Options.http://www.slovaktech.com/products.htm
I was given the task of pulling all of the sent and received items for
a user for the previous day and writing it to an Excel folder. Task
Completed!
I tested this on my Inbox, but my boss wants me to run it on a
subfolder located in his "Search Folders". Apparently Outlook does
not recognize "Search Folders" as a mailbox folder.
So my question is, how can I access this folder?
Thanks Ken.
Unfortunately, Outlook 2003.  We do have and use Redemption, so I'm
hoping I can find an example on his site because I'm not sure I can
figure put how to write this.
Thank you very much Dmitry.
McKilty
2009-09-30 13:12:16 UTC
Permalink
Post by McKilty
Seehttp://www.dimastr.com/redemption/rdo/rdosearches.htm
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
On Sep 29, 4:02 pm, "Ken Slovak - [MVP - Outlook]"
Post by Ken Slovak - [MVP - Outlook]
Outlook version?
In Outlook 2007 you'd use NameSpace.DefaultStore.GetSearchFolders() to get
the Folders collection of search folders. From there you can get the one of
interest.
In Outlook 2003 or earlier you'd need to be using a different API such as
Redemption (www.dimastr.com).
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment
Options.http://www.slovaktech.com/products.htm
I was given the task of pulling all of the sent and received items for
a user for the previous day and writing it to an Excel folder. Task
Completed!
I tested this on my Inbox, but my boss wants me to run it on a
subfolder located in his "Search Folders". Apparently Outlook does
not recognize "Search Folders" as a mailbox folder.
So my question is, how can I access this folder?
Thanks Ken.
Unfortunately, Outlook 2003.  We do have and use Redemption, so I'm
hoping I can find an example on his site because I'm not sure I can
figure put how to write this.
Thank you very much Dmitry.
I'm afraid I need more help. So, again, what we want to do is all all
the Sent & Received items for the previous day. Then we record the
From, To, CC, Subject, and first 100 characters in a spreadsheet.

Using Dmitry's code, I was able to find the folder, but I don't know
how to access the items in it.

1 - Can I set a Collections to the search folder so I can then filter
as normal?

I realize that I could also create a search folder on the fly for the
previous day rather than filter, but still, I need to know how to
access the e-mails and pull the info.


Here is my code so far:


-------------------------------------------------------------------------------------------
Dim iMailItem As Integer
Dim dteStart As String
Dim dteEnd As String

Dim myOutlook As Outlook.Application
Dim myNameSpace As Namespace
Dim mItemCollection As Items
Dim myMailItem As MailItem
'Dim myEmail As Outlook.MailItem

Dim SafeMail

Dim sUser As String
Dim sMailbox As String
Dim sFolder As String
Dim sSaveLocation As String

Dim Session
Dim Search
Dim Searches
Dim SRFolder

'On Error GoTo ErrorHandler

'U S E R V A R I A B L E S

''Rick Bray
******************************************************************
sUser = "rbray"
sMailbox = "Mailbox - Bray, Rick"

dteStart = (Date - 1 & " 00:00")
dteEnd = (Date - 1 & " 23:59")

Set myOutlook = CreateObject("Outlook.Application")
Set myNameSpace = myOutlook.GetNamespace("MAPI")

Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set Searches = Session.Stores.DefaultStore.Searches
For i = 1 To Searches.Count
Set Search = Searches.Item(i)
If Search.Name = "Current Sent & Received" Then
Exit For
End If
Next


'I don't know what this line does or what I can/should do with it.
SRFolder = Search.GetFolder(True)


' This next section is from my existing code.
' I'd like to set mItemCollection to SRFolder, or the contents of
Search, but I can't figure that out.

Set mItemCollection = myNameSpace.Folders(sMailbox).Folders("Search
Folders").Folders("Current Sent & Received")

'Set Filter to previous day
Set mItemCollection = mItemCollection.Restrict("[SentOn] >= '" &
dteStart & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] <= '" &
dteEnd & "'")
mItemCollection.Sort "[SentOn]", False

For iMailItem = 1 To mItemCollection.Count
Set myMailItem = mItemCollection.Item(iMailItem)
Set SafeMail = CreateObject("Redemption.SafeMailItem")
SafeMail.Item = myMailItem

sSender = SafeMail.SenderName
sSentTo = SafeMail.To


etc.

-------------------------------------------------------------------------------------------

Thanks for your help.
Ken Slovak - [MVP - Outlook]
2009-09-30 13:31:49 UTC
Permalink
Once you get the search folder reference it's just another folder with an
Items collection. You'd iterate the Items collection as you would with any
other folder.

If you create a search folder yourself in code you can get the MAPIFolder
reference passed by the Save() function and get the folder EntryID and use
that later to get the folder using NameSpace.GetFolderFromID(). After that
you work with the Items collection.

I'm not sure what your code is trying to do other than using non-existent
properties from Redemption. There is no RDOStore.Searches property or
collection to work with, I'm not sure where you came up with that.

Code like this will get you to the search root folder, from there you
iterate the folders collection of the search root:

Dim SearchRoot As Redemption.RDOFolder

Set SearchRoot = Session.Stores.DefaultStore.SearchRootFolder
Set Search = SearchRoot.Folders.Item("Current Sent & Received")
Set searchItems = Search.Items ' RDOItems

Then just iterate the items collection.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"McKilty" <***@gmail.com> wrote in message news:386b85b7-5560-4736-86cc-***@g31g2000yqc.googlegroups.com...
On Sep 29, 5:01 pm, McKilty <***@gmail.com> wrote:
<snip>

I'm afraid I need more help. So, again, what we want to do is all all
the Sent & Received items for the previous day. Then we record the
From, To, CC, Subject, and first 100 characters in a spreadsheet.

Using Dmitry's code, I was able to find the folder, but I don't know
how to access the items in it.

1 - Can I set a Collections to the search folder so I can then filter
as normal?

I realize that I could also create a search folder on the fly for the
previous day rather than filter, but still, I need to know how to
access the e-mails and pull the info.


Here is my code so far:


-------------------------------------------------------------------------------------------
Dim iMailItem As Integer
Dim dteStart As String
Dim dteEnd As String

Dim myOutlook As Outlook.Application
Dim myNameSpace As Namespace
Dim mItemCollection As Items
Dim myMailItem As MailItem
'Dim myEmail As Outlook.MailItem

Dim SafeMail

Dim sUser As String
Dim sMailbox As String
Dim sFolder As String
Dim sSaveLocation As String

Dim Session
Dim Search
Dim Searches
Dim SRFolder

'On Error GoTo ErrorHandler

'U S E R V A R I A B L E S

''Rick Bray
******************************************************************
sUser = "rbray"
sMailbox = "Mailbox - Bray, Rick"

dteStart = (Date - 1 & " 00:00")
dteEnd = (Date - 1 & " 23:59")

Set myOutlook = CreateObject("Outlook.Application")
Set myNameSpace = myOutlook.GetNamespace("MAPI")

Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set Searches = Session.Stores.DefaultStore.Searches
For i = 1 To Searches.Count
Set Search = Searches.Item(i)
If Search.Name = "Current Sent & Received" Then
Exit For
End If
Next


'I don't know what this line does or what I can/should do with it.
SRFolder = Search.GetFolder(True)


' This next section is from my existing code.
' I'd like to set mItemCollection to SRFolder, or the contents of
Search, but I can't figure that out.

Set mItemCollection = myNameSpace.Folders(sMailbox).Folders("Search
Folders").Folders("Current Sent & Received")

'Set Filter to previous day
Set mItemCollection = mItemCollection.Restrict("[SentOn] >= '" &
dteStart & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] <= '" &
dteEnd & "'")
mItemCollection.Sort "[SentOn]", False

For iMailItem = 1 To mItemCollection.Count
Set myMailItem = mItemCollection.Item(iMailItem)
Set SafeMail = CreateObject("Redemption.SafeMailItem")
SafeMail.Item = myMailItem

sSender = SafeMail.SenderName
sSentTo = SafeMail.To


etc.

-------------------------------------------------------------------------------------------

Thanks for your help.
McKilty
2009-09-30 13:49:42 UTC
Permalink
On Sep 30, 9:31 am, "Ken Slovak - [MVP - Outlook]"
Post by Ken Slovak - [MVP - Outlook]
Once you get the search folder reference it's just another folder with an
Items collection. You'd iterate the Items collection as you would with any
other folder.
If you create a search folder yourself in code you can get the MAPIFolder
reference passed by the Save() function and get the folder EntryID and use
that later to get the folder using NameSpace.GetFolderFromID(). After that
you work with the Items collection.
I'm not sure what your code is trying to do other than using non-existent
properties from Redemption. There is no RDOStore.Searches property or
collection to work with, I'm not sure where you came up with that.
Code like this will get you to the search root folder, from there you
Dim SearchRoot As Redemption.RDOFolder
Set SearchRoot = Session.Stores.DefaultStore.SearchRootFolder
Set Search = SearchRoot.Folders.Item("Current Sent & Received")
Set searchItems = Search.Items ' RDOItems
Then just iterate the items collection.
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
Thanks Ken. I'll give that a shot. As for where I got the code, I
copied it from Dmitry's site. All I did was alter it to stop when it
found the folder I wanted.


--------------
My Code
--------------
Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set Searches = Session.Stores.DefaultStore.Searches
For i = 1 To Searches.Count
Set Search = Searches.Item(i)
If Search.Name = "Current Sent & Received" Then
Exit For
End If
Next

---------------------
Dmitry's Code
---------------------
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Searches = Session.Stores.DefaultStore.Searches
for i = 1 to Searches.Count
set Search = Searches.Item(i)
Debug.Print Search.Name & ": " & Search.SearchCriteria.AsSQL
next


The line that reads "SRFolder = Search.GetFolder(True) " is one that I
wrote as I tried to experiment. I don't know what it does though, so
I'll remove that. ;)


Anyway, thanks again.
Ken Slovak - [MVP - Outlook]
2009-09-30 15:41:13 UTC
Permalink
That's very odd. According to the Web site RDOStore2 was added in version
4.7.0.1026, and I'm running 4.8.0.1090 here but it doesn't have RDOStore2 in
its object model or in the Object Browser. There seems to be some sort of
breach in COM compatibility going on with various versions of Redemption.
Let's see what Dmitry says.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"McKilty" <***@gmail.com> wrote in message news:29c45f23-639d-41b8-859f-***@d10g2000yqh.googlegroups.com...
<snip>

Thanks Ken. I'll give that a shot. As for where I got the code, I
copied it from Dmitry's site. All I did was alter it to stop when it
found the folder I wanted.


--------------
My Code
--------------
Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set Searches = Session.Stores.DefaultStore.Searches
For i = 1 To Searches.Count
Set Search = Searches.Item(i)
If Search.Name = "Current Sent & Received" Then
Exit For
End If
Next

---------------------
Dmitry's Code
---------------------
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Searches = Session.Stores.DefaultStore.Searches
for i = 1 to Searches.Count
set Search = Searches.Item(i)
Debug.Print Search.Name & ": " & Search.SearchCriteria.AsSQL
next


The line that reads "SRFolder = Search.GetFolder(True) " is one that I
wrote as I tried to experiment. I don't know what it does though, so
I'll remove that. ;)


Anyway, thanks again.
Ken Slovak - [MVP - Outlook]
2009-09-30 17:29:22 UTC
Permalink
OK, I figured it out with Dmitry. The Web site calls it RDOStore2 but in the
object model and object browser it's IRDOStore2 and you have to cast your
store to an RDOExchangeMailboxStore or RDOPstStore object to get access to
the Searches collection.

So for VBA code you could use something like this, assuming you're using a
PST file as your default store:

Dim oStore As Redemption.RDOPstStore

Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set oStore = Session.Stores.DefaultStore
Set Searches = oStore.Searches

Set Search = Searches.Item("Current Sent & Received")

If you're using an Exchange mailbox substitute RDOExchangeMailboxStore in
the declaration of oStore.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by Ken Slovak - [MVP - Outlook]
That's very odd. According to the Web site RDOStore2 was added in version
4.7.0.1026, and I'm running 4.8.0.1090 here but it doesn't have RDOStore2
in its object model or in the Object Browser. There seems to be some sort
of breach in COM compatibility going on with various versions of
Redemption. Let's see what Dmitry says.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
<snip>
Thanks Ken. I'll give that a shot. As for where I got the code, I
copied it from Dmitry's site. All I did was alter it to stop when it
found the folder I wanted.
--------------
My Code
--------------
Set Session = CreateObject("Redemption.RDOSession")
Session.Logon
Set Searches = Session.Stores.DefaultStore.Searches
For i = 1 To Searches.Count
Set Search = Searches.Item(i)
If Search.Name = "Current Sent & Received" Then
Exit For
End If
Next
---------------------
Dmitry's Code
---------------------
set Session = CreateObject("Redemption.RDOSession")
Session.Logon
set Searches = Session.Stores.DefaultStore.Searches
for i = 1 to Searches.Count
set Search = Searches.Item(i)
Debug.Print Search.Name & ": " & Search.SearchCriteria.AsSQL
next
The line that reads "SRFolder = Search.GetFolder(True) " is one that I
wrote as I tried to experiment. I don't know what it does though, so
I'll remove that. ;)
Anyway, thanks again.
McKilty
2009-09-30 18:46:09 UTC
Permalink
I ended up using your original example and got it working. I had to
drop the hyperlink to the e-mail for now, but I hope to revisit that
later.

Thanks so much for your help. I'm completely self taught, so
obviously I struggle quite a bit. ;)
McKilty
2009-09-30 20:56:08 UTC
Permalink
OK, on to hyperlinks...

When I wrote this for a regular folder it worked, but for the Search
Folders, it does not work. My hyperlink is:

sHyperLink = "outlook:search folders\Current Sent & Received\" &
mItemCollection.Item(iMailItem).EntryID


It is getting the EntryID OK, but I'm thinking you cannot link to the
Search Folders. Is there a way to get the objects original location
and link back to it?
Ken Slovak - [MVP - Outlook]
2009-09-30 21:16:01 UTC
Permalink
A search folder is a virtual folder that shows items from one or more
folders that meet a filter. The items actually live in their original
folders.

Using indexed access to an item in a search folder is error prone due to
item moving around in the collection as more or fewer items meet the filter
criteria. In fact persisting indexed access to any member of any Items
collection is error prone. Say you are linking to items in Inbox, how often
does that collection get changed?

Your hyperlinks should all be in the format "Outlook:entryID". That way as
long as the items still exist in the same folder you will reference them.
With PST files, where EntryID doesn't change if the item remains in the
store, you would be able to reference the correct items even if they were
moved to different folders. That wouldn't work with Exchange stores or if
items were moved from one store to another.

With a current collection index you can get the actual parent folder name
from the item this way, assuming folder.Items.Item(iMailItem).Parent.Name.
You can get the EntryID as a string the same way.

See http://www.slipstick.com/outlook/links.htm for information on formatting
various sorts of links.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
Post by McKilty
OK, on to hyperlinks...
When I wrote this for a regular folder it worked, but for the Search
sHyperLink = "outlook:search folders\Current Sent & Received\" &
mItemCollection.Item(iMailItem).EntryID
It is getting the EntryID OK, but I'm thinking you cannot link to the
Search Folders. Is there a way to get the objects original location
and link back to it?
McKilty
2009-09-30 21:59:17 UTC
Permalink
Thanks Ken, I'll give that a shot.


So, I said I got it working... well, of course that's on my
development computer. When I run it on the end-users computer I get
an error when I try to use a filter. The exact line of code it
crashes on is:

---------------------------------
Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
dteStart & "' AND [SentOn] < '" & dteEnd & "'")
---------------------------------

The error is

Run-time error '438':
Object doesn't support this property or method


The Code that proceeds this is:

----------------------------------
Dim dteStart As String
Dim dteEnd As String

Dim myOutlook As Outlook.Application
Dim myNameSpace As Namespace
Dim myMailItem

Dim sUser As String
Dim sMailbox As String
Dim sSaveLocation As String

Dim Session
Dim Search
Dim SearchRoot As Redemption.RDOFolder

On Error GoTo ErrorHandler

'U S E R V A R I A B L E S

' Rick Bray
******************************************************************
sUser = "rbray"
sMailbox = "Mailbox - Bray, Rick"

dteStart = (Date - 1 & " 00:00")
dteEnd = (Date - 1 & " 23:59")

Set myOutlook = CreateObject("Outlook.Application")
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set Session = CreateObject("Redemption.RDOSession")
Session.Logon

Set SearchRoot = Session.Stores.DefaultStore.SearchRootFolder
Set Search = SearchRoot.Folders.Item("Current Sent & Received")

Set mItemCollection = Search.Items ' RDOItems
Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
dteStart & "' AND [SentOn] < '" & dteEnd & "'")
'<-------------------------- FAIL
----------------------------------

I also tried:

'Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" & Format
(dteStart, "yyyy-mm-dd") & "' AND [SentOn] < '" & Format(dteEnd, "yyyy-
mm-dd") & "'")

AND

'Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
dteStart & "'")
'Set mItemCollection = mItemCollection.Restrict("[SentOn] < '" &
dteEnd & "'")


They all fail. I stumped on this one because like I said, it works on
my computer but not hers.

Thank you so much for your help.
McKilty
2009-09-30 22:18:52 UTC
Permalink
Ok, before anyone gets too involved on this, I ended up changing

Dim dteStart as string

to a date, and then back to a string and it worked. This makes no
sense, so I may be mistaken. Anyway, now it kinda works...


This line filters the e-mails to NOTHING.
Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" & Format
(dteStart, "yyyy-mm-dd") & "' AND [SentOn] < '" & Format(dteEnd, "yyyy-
mm-dd") & "'")


These lines I don't work because the second line overwrites the first
line and I just get everything BEFORE the end date.
Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" & Format
(dteStart, "yyyy-mm-dd") & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] < '" & Format
(dteEnd, "yyyy-mm-dd") & "'")
McKilty
2009-09-30 22:42:46 UTC
Permalink
It's all working. I don't even know what changed. Either magic is
involved, code fairies, or I've been at this too long that I became
cross-eyed and can't read my own code anymore.


Thanks for all your help Ken, Dmitry, and Sue (from another thread.)
McKilty
2009-09-29 20:35:41 UTC
Permalink
On Sep 29, 4:02 pm, "Ken Slovak - [MVP - Outlook]"
Post by Ken Slovak - [MVP - Outlook]
Outlook version?
In Outlook 2007 you'd use NameSpace.DefaultStore.GetSearchFolders() to get
the Folders collection of search folders. From there you can get the one of
interest.
In Outlook 2003 or earlier you'd need to be using a different API such as
Redemption (www.dimastr.com).
--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.http://www.slovaktech.com/products.htm
I was given the task of pulling all of the sent and received items for
a user for the previous day and writing it to an Excel folder.  Task
Completed!
I tested this on my Inbox, but my boss wants me to run it on a
subfolder located in his "Search Folders".  Apparently Outlook does
not recognize "Search Folders" as a mailbox folder.
So my question is, how can I access this folder?
Thanks Ken.

Unfortunately, Outlook 2003. We do have and use Redemption, so I'm
hoping I can find an example on his site because I'm not sure I can
figure put how to write this.
Loading...