Restrict Method [ReceivedTime] DNW

G

Guest

Hello! I am trying to set up a filter where I can restrict retrieved messages
from an Outlook 98 account using the ReceivedTime, Restrict method, and a
dynamically assigned date range:

Set myItms = objFolder.Items
DateFrom = Format(DateFrom, "ddddd h:nn AMPM")
DateTo = Format(DateTo, "ddddd h:nn AMPM")
sFilterFrom = "[ReceivedTime] >= " & Chr(34) & Format(DateFrom, "mmm, dd
yyyy") & " 12:00 AM " & Chr(34)
sFilterTo = "[ReceivedTime] < " & Chr(34) & Format(DateTo, "mmm, dd yyyy") &
" 12:00 AM" & Chr(34)
' DNW sFilterFrom = "[ReceivedTime] >= " & Chr(34) &
Format(DateFrom, "mm/dd/yyyy") & Chr(34)
' DNW sFilterTo = "[ReceivedTime] < " & Chr(34) & Format(DateTo,
"mm/dd/yyyy") & Chr(34)

sFilter = sFilterFrom & " AND " & sFilterTo
' MsgBox (sFilter)

Set myItms = myItms.Restrict(sFilter)

'>>>>>>>>>>>>>>>> Restrict does not work


'myItms.SetColumns ("BillingInformation")
' myItms.SetColumns ("[ReceivedTime],[BillingInformation]")
' myItms.Sort "BillingInformation", False


If myItms.count > 0 Then
For Each itm In myItms

If itm.Unread = True Then
'On Error Resume Next
ReceivedTime = itm.ReceivedTime
If ReceivedTime <= DateAdd("m", -1, Now) Then
MsgBox ("Problem.....")
End If

Todays Date is 9/29/2005.
I am using a DateFrom value of 9/1/2005 and a DateTo value of 10/1/2005. I
have the On Error Resume Next statment commented out.
SFilter becomes:
sFilter = [ReceivedTime] >= "Sep, 01 2005 12:00 AM" AND [ReceivedTime] <
"Sep, 20 2005 12:00 AM"

This does not throw an error but also does not filter out messages that do
not meet the sFilter condition. What am I doing wrong?

Thanks so much for your help
 
S

Sue Mosher [MVP-Outlook]

Does myItms.count return too many items or too few?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Too many. It returns all the items in the folder. Thanks for looking at
this Sue.

Ed

Sue Mosher said:
Does myItms.count return too many items or too few?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



emanson said:
Hello! I am trying to set up a filter where I can restrict retrieved messages
from an Outlook 98 account using the ReceivedTime, Restrict method, and a
dynamically assigned date range:

Set myItms = objFolder.Items
DateFrom = Format(DateFrom, "ddddd h:nn AMPM")
DateTo = Format(DateTo, "ddddd h:nn AMPM")
sFilterFrom = "[ReceivedTime] >= " & Chr(34) & Format(DateFrom, "mmm, dd
yyyy") & " 12:00 AM " & Chr(34)
sFilterTo = "[ReceivedTime] < " & Chr(34) & Format(DateTo, "mmm, dd yyyy") &
" 12:00 AM" & Chr(34)
' DNW sFilterFrom = "[ReceivedTime] >= " & Chr(34) &
Format(DateFrom, "mm/dd/yyyy") & Chr(34)
' DNW sFilterTo = "[ReceivedTime] < " & Chr(34) & Format(DateTo,
"mm/dd/yyyy") & Chr(34)

sFilter = sFilterFrom & " AND " & sFilterTo
' MsgBox (sFilter)

Set myItms = myItms.Restrict(sFilter)

'>>>>>>>>>>>>>>>> Restrict does not work


'myItms.SetColumns ("BillingInformation")
' myItms.SetColumns ("[ReceivedTime],[BillingInformation]")
' myItms.Sort "BillingInformation", False


If myItms.count > 0 Then
For Each itm In myItms

If itm.Unread = True Then
'On Error Resume Next
ReceivedTime = itm.ReceivedTime
If ReceivedTime <= DateAdd("m", -1, Now) Then
MsgBox ("Problem.....")
End If

Todays Date is 9/29/2005.
I am using a DateFrom value of 9/1/2005 and a DateTo value of 10/1/2005. I
have the On Error Resume Next statment commented out.
SFilter becomes:
sFilter = [ReceivedTime] >= "Sep, 01 2005 12:00 AM" AND [ReceivedTime] <
"Sep, 20 2005 12:00 AM"

This does not throw an error but also does not filter out messages that do
not meet the sFilter condition. What am I doing wrong?

Thanks so much for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Restrict Method DNW 14

Top