Discussion:
All day events only show up for first day
(too old to reply)
M
2010-02-10 14:37:02 UTC
Permalink
Hello:

I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the calendar.
Outlook is smart enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't clear,
I'll give an example:

I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.

It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?

Thank you.
--
Regards,
M
MCTS, MCSA
Sue Mosher [MVP]
2010-02-10 15:04:14 UTC
Permalink
Show the code that builds the query, please.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the
calendar. Outlook is smart enough to show the event spanning several days,
but it only stores the entry on the start date. In case my explanation
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?
Thank you.
--
Regards,
M
MCTS, MCSA
M
2010-02-10 15:52:29 UTC
Permalink
Here's the code.

Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 = objCalItemFilter.Fields.Add(CdoPR_START_DATE,
dtmTimeEnd) 'This is the END date! The values for start and end times must
be reversed. See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 = objCalItemFilter.Fields.Add(CdoPR_END_DATE,
dtmTimeStart) 'This is the START date! The values for start and end times
must be reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
Show the code that builds the query, please.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events
which span several days actually consists of only a single entry in the
calendar. Outlook is smart enough to show the event spanning several
days, but it only stores the entry on the start date. In case my
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this,
so that when my script looks at Tuesday and Wednesday, it would see the
3-day event?
Thank you.
--
Regards,
M
MCTS, MCSA
Sue Mosher [MVP]
2010-02-10 16:38:41 UTC
Permalink
What are typical values for dtmTimeEnd and dtmTimeStart. As the article you
cited explains, the query needs to look for items that start before the end
date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an illogical
approach at first.

To ask the question another way, how exactly do you invoke the code when "my
script looks at Tuesday and Wednesday"?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 = objCalItemFilter.Fields.Add(CdoPR_START_DATE,
dtmTimeEnd) 'This is the END date! The values for start and end times must
be reversed. See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 = objCalItemFilter.Fields.Add(CdoPR_END_DATE,
dtmTimeStart) 'This is the START date! The values for start and end times
must be reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range. I've
almost got eveverything working, but one thing I noticed is that all day
events which span several days actually consists of only a single entry
in the calendar. Outlook is smart enough to show the event spanning
several days, but it only stores the entry on the start date. In case my
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this,
so that when my script looks at Tuesday and Wednesday, it would see the
3-day event?
M
2010-02-10 16:59:45 UTC
Permalink
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)

I set the filter range using the two variables above, and then go through
each day within that range to look for items in each day's calendar.
Eventually I send the info via e-mail.

Everything so far is working correctly. I see single entries, such as Monday
12:00 PM - 1:00 PM, and recurrences. But the script only reads the first day
of all day events that span multiple days. This is seems to be the way
Outlook works, so I don't think it's problem, per se, but I need to try to
work around that if possible.

Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the article
you cited explains, the query needs to look for items that start before
the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code when
"my script looks at Tuesday and Wednesday"?
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is the
END date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 = objCalItemFilter.Fields.Add(CdoPR_END_DATE,
dtmTimeStart) 'This is the START date! The values for start and end times
must be reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range.
I've almost got eveverything working, but one thing I noticed is that
all day events which span several days actually consists of only a
single entry in the calendar. Outlook is smart enough to show the event
spanning several days, but it only stores the entry on the start date.
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on Monday.
When the script looks at Tuesday and Wednesday, it doesn't see the
event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this,
so that when my script looks at Tuesday and Wednesday, it would see the
3-day event?
Sue Mosher [MVP]
2010-02-10 18:14:26 UTC
Permalink
How do you "go through each day within that range"?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go through
each day within that range to look for items in each day's calendar.
Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads the
first day of all day events that span multiple days. This is seems to be
the way Outlook works, so I don't think it's problem, per se, but I need
to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the article
you cited explains, the query needs to look for items that start before
the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code when
"my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is the
END date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 = objCalItemFilter.Fields.Add(CdoPR_END_DATE,
dtmTimeStart) 'This is the START date! The values for start and end
times must be reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range.
I've almost got eveverything working, but one thing I noticed is that
all day events which span several days actually consists of only a
single entry in the calendar. Outlook is smart enough to show the
event spanning several days, but it only stores the entry on the start
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on Monday.
When the script looks at Tuesday and Wednesday, it doesn't see the
event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around
this, so that when my script looks at Tuesday and Wednesday, it would
see the 3-day event?
M
2010-02-10 18:38:03 UTC
Permalink
I loop through the collection returned for the date range as shown below.

For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go through
each day within that range to look for items in each day's calendar.
Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads the
first day of all day events that span multiple days. This is seems to be
the way Outlook works, so I don't think it's problem, per se, but I need
to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the article
you cited explains, the query needs to look for items that start before
the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code when
"my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is the
END date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is the
START date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range.
I've almost got eveverything working, but one thing I noticed is that
all day events which span several days actually consists of only a
single entry in the calendar. Outlook is smart enough to show the
event spanning several days, but it only stores the entry on the
start date. In case my explanation wasn't clear, I'll give an
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on Monday.
When the script looks at Tuesday and Wednesday, it doesn't see the
event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around
this, so that when my script looks at Tuesday and Wednesday, it would
see the 3-day event?
Sue Mosher [MVP]
2010-02-10 18:50:38 UTC
Permalink
The collection for the full 16-day date range? As JP suggested, you'll need
to keep track of the dates involved in all-day events. Each such appointment
will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is seems
to be the way Outlook works, so I don't think it's problem, per se, but
I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the article
you cited explains, the query needs to look for items that start before
the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is the
END date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is the
START date! The values for start and end times must be reversed. See
http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range.
I've almost got eveverything working, but one thing I noticed is
that all day events which span several days actually consists of
only a single entry in the calendar. Outlook is smart enough to show
the event spanning several days, but it only stores the entry on the
start date. In case my explanation wasn't clear, I'll give an
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it doesn't
see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around
this, so that when my script looks at Tuesday and Wednesday, it
would see the 3-day event?
M
2010-02-10 19:15:34 UTC
Permalink
Ok, that's what I was trying to find out. The appointment only appears once,
basically because it's tied to the start date only, correct? Is there any
way to work around this? I just need some ideas--I should be able to write
the code. Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The collection for the full 16-day date range? As JP suggested, you'll
need to keep track of the dates involved in all-day events. Each such
appointment will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is seems
to be the way Outlook works, so I don't think it's problem, per se, but
I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the
article you cited explains, the query needs to look for items that
start before the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder = objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is
the END date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is
the START date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date range.
I've almost got eveverything working, but one thing I noticed is
that all day events which span several days actually consists of
only a single entry in the calendar. Outlook is smart enough to
show the event spanning several days, but it only stores the entry
on the start date. In case my explanation wasn't clear, I'll give
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it doesn't
see the event at all.
It seems that this issue is by design, and seems logical to me, so
I understand why this is happening. Is there any way to work around
this, so that when my script looks at Tuesday and Wednesday, it
would see the 3-day event?
M
2010-02-10 19:21:49 UTC
Permalink
In addition to my last comment, what if the all day event starts on a date
that is before the range of the collection? Will the collection even see the
event? I'm going to test this shortly.
--
Regards,
M
MCTS, MCSA
Post by M
Ok, that's what I was trying to find out. The appointment only appears
once, basically because it's tied to the start date only, correct? Is
there any way to work around this? I just need some ideas--I should be
able to write the code. Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The collection for the full 16-day date range? As JP suggested, you'll
need to keep track of the dates involved in all-day events. Each such
appointment will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is seems
to be the way Outlook works, so I don't think it's problem, per se,
but I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the
article you cited explains, the query needs to look for items that
start before the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder =
objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is
the END date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is
the START date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date
range. I've almost got eveverything working, but one thing I
noticed is that all day events which span several days actually
consists of only a single entry in the calendar. Outlook is smart
enough to show the event spanning several days, but it only stores
the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it doesn't
see the event at all.
It seems that this issue is by design, and seems logical to me, so
I understand why this is happening. Is there any way to work
around this, so that when my script looks at Tuesday and
Wednesday, it would see the 3-day event?
Sue Mosher [MVP]
2010-02-10 19:39:44 UTC
Permalink
Yes.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
In addition to my last comment, what if the all day event starts on a date
that is before the range of the collection? Will the collection even see
the event? I'm going to test this shortly.
Post by M
Ok, that's what I was trying to find out. The appointment only appears
once, basically because it's tied to the start date only, correct? Is
there any way to work around this? I just need some ideas--I should be
able to write the code. Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The collection for the full 16-day date range? As JP suggested, you'll
need to keep track of the dates involved in all-day events. Each such
appointment will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is
seems to be the way Outlook works, so I don't think it's problem, per
se, but I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the
article you cited explains, the query needs to look for items that
start before the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder =
objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is
the END date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is
the START date! The values for start and end times must be
reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date
range. I've almost got eveverything working, but one thing I
noticed is that all day events which span several days actually
consists of only a single entry in the calendar. Outlook is smart
enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it
doesn't see the event at all.
It seems that this issue is by design, and seems logical to me,
so I understand why this is happening. Is there any way to work
around this, so that when my script looks at Tuesday and
Wednesday, it would see the 3-day event?
Sue Mosher [MVP]
2010-02-10 19:39:46 UTC
Permalink
The workaround is the one you've already been given: If you want the event
to appear on each day of your printout, your code must keep track of which
days the all-day event should appear on.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
Ok, that's what I was trying to find out. The appointment only appears
once, basically because it's tied to the start date only, correct? Is
there any way to work around this? I just need some ideas--I should be
able to write the code. Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The collection for the full 16-day date range? As JP suggested, you'll
need to keep track of the dates involved in all-day events. Each such
appointment will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is seems
to be the way Outlook works, so I don't think it's problem, per se,
but I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the
article you cited explains, the query needs to look for items that
start before the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder =
objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is
the END date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is
the START date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date
range. I've almost got eveverything working, but one thing I
noticed is that all day events which span several days actually
consists of only a single entry in the calendar. Outlook is smart
enough to show the event spanning several days, but it only stores
the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it doesn't
see the event at all.
It seems that this issue is by design, and seems logical to me, so
I understand why this is happening. Is there any way to work
around this, so that when my script looks at Tuesday and
Wednesday, it would see the 3-day event?
M
2010-02-10 19:52:28 UTC
Permalink
Thank you. So it was the collection that was the issue, not the way Outlook
stores all day events, as I had thought. At least now I know what was
causing the event to only show up once.

I ran a test and even if the event started before the date range, it will
still show up in the collection as long as the event falls within the date
range. But the collection will only return the first instance of the event
within the date range.

I'm not going to write code to compensate for this--I'll just inform the
recipients of the e-mail to pay attention to the dates of all day events,
since they could be the multi-day events.

Thank you again.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The workaround is the one you've already been given: If you want the event
to appear on each day of your printout, your code must keep track of which
days the all-day event should appear on.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
Ok, that's what I was trying to find out. The appointment only appears
once, basically because it's tied to the start date only, correct? Is
there any way to work around this? I just need some ideas--I should be
able to write the code. Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
The collection for the full 16-day date range? As JP suggested, you'll
need to keep track of the dates involved in all-day events. Each such
appointment will appear in the collection only once.
--
Sue Mosher, Outlook MVP
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
Post by M
I loop through the collection returned for the date range as shown below.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS (IF
AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by Sue Mosher [MVP]
How do you "go through each day within that range"?
Post by M
dtmTimeStart is today's date
dtmTimeEnd is today's + 16 (or any number)
I set the filter range using the two variables above, and then go
through each day within that range to look for items in each day's
calendar. Eventually I send the info via e-mail.
Everything so far is working correctly. I see single entries, such as
Monday 12:00 PM - 1:00 PM, and recurrences. But the script only reads
the first day of all day events that span multiple days. This is
seems to be the way Outlook works, so I don't think it's problem, per
se, but I need to try to work around that if possible.
Thank you.
--
Regards,
M
MCTS, MCSA
Post by Sue Mosher [MVP]
What are typical values for dtmTimeEnd and dtmTimeStart. As the
article you cited explains, the query needs to look for items that
start before the end date and end after the start date. The article at
http://blogs.msdn.com/waltwa/archive/2007/03/14/finding-appointments-within-a-specific-timeframe.aspx
provides a nice graphical representation of what may seem like an
illogical approach at first.
To ask the question another way, how exactly do you invoke the code
when "my script looks at Tuesday and Wednesday"?
Post by M
Here's the code.
Set objCDOSession = CreateObject("MAPI.Session")
objCDOSession.Logon , , , , , , strMAPIProfile
Set objCalFolder =
objCDOSession.GetDefaultFolder(CdoCALENDAR_FOLDER)
Set objCalItemColl = objCalFolder.Messages
Set objCalItemFilter = objCalItemColl.Filter
Set objCalItemFilterField1 =
objCalItemFilter.Fields.Add(CdoPR_START_DATE, dtmTimeEnd) 'This is
the END date! The values for start and end times must be reversed.
See http://support.microsoft.com/kb/192404.
Set objCalItemFilterField2 =
objCalItemFilter.Fields.Add(CdoPR_END_DATE, dtmTimeStart) 'This is
the START date! The values for start and end times must be
reversed. See http://support.microsoft.com/kb/192404.
For Each objCalItemSingle In objCalItemColl
If objCalItemSingle.AllDayEvent Then
strEmailBodyText = strEmailBodyText & "SUBJECT: [ALL DAY EVENT] " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
Else
strEmailBodyText = strEmailBodyText & "SUBJECT: " &
objCalItemSingle.Subject & vbCRLF & " | START TIME: " &
objCalItemSingle.StartTime & vbCRLF & _
" | END TIME: " & objCalItemSingle.EndTime & vbCRLF & " | DETAILS
(IF AVAILABLE): " & objCalItemSingle.Text & vbCRLF & vbCRLF
End If
Set objCalItemSingle = objCalItemColl.GetNext
Next
Post by M
I created a VBS script using CDO to look at all the items in a
particular Exchange mailbox calendar between a specific date
range. I've almost got eveverything working, but one thing I
noticed is that all day events which span several days actually
consists of only a single entry in the calendar. Outlook is smart
enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the
script only sees one entry for the 3-day event, and that's on
Monday. When the script looks at Tuesday and Wednesday, it
doesn't see the event at all.
It seems that this issue is by design, and seems logical to me,
so I understand why this is happening. Is there any way to work
around this, so that when my script looks at Tuesday and
Wednesday, it would see the 3-day event?
JP
2010-02-10 15:09:30 UTC
Permalink
Create three separate all-day events instead? Or are you creating ONE
all-day event and telling Outlook that it runs from Monday through
Wednesday? You might want to post your code.

--JP
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the calendar.
Outlook is smart enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?
Thank you.
--
Regards,
M
MCTS, MCSA
M
2010-02-10 15:55:32 UTC
Permalink
To clarify, my script is only reading events that were posted manually by
users. If a user has a 3-day vacation, then the user would make a 3-day all
day event for that, because that's the natural thing to do and makes sense.
I can't tell the user to create 3 individual events just to get my code to
work. I posted the code in reply to Sue's reply.
--
Regards,
M
MCTS, MCSA
"JP" <***@earthlink.net> wrote in message news:039311e8-8770-4d77-80c4-***@v36g2000vbs.googlegroups.com...
Create three separate all-day events instead? Or are you creating ONE
all-day event and telling Outlook that it runs from Monday through
Wednesday? You might want to post your code.

--JP
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the calendar.
Outlook is smart enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?
Thank you.
--
Regards,
M
MCTS, MCSA
JP
2010-02-10 18:05:51 UTC
Permalink
Gotcha, I thought you were setting them up on your own computer that
way.

Are you trying to calculate how many days the event lasts?

Couldn't your script grab the start date/time and end date/time and
calculate how many days it's for?

Or am I missing something.

--JP
Post by M
To clarify, my script is only reading events that were posted manually by
users. If a user has a 3-day vacation, then the user would make a 3-day all
day event for that, because that's the natural thing to do and makes sense.
I can't tell the user to create 3 individual events just to get my code to
work. I posted the code in reply to Sue's reply.
--
Regards,
M
Create three separate all-day events instead? Or are you creating ONE
all-day event and telling Outlook that it runs from Monday through
Wednesday? You might want to post your code.
--JP
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the calendar.
Outlook is smart enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?
Thank you.
--
Regards,
M
MCTS, MCSA- Hide quoted text -
- Show quoted text -
M
2010-02-10 19:13:31 UTC
Permalink
I don't need to calculate how many days the event lasts. If I had to, I
could do it though, so that's not the issue. I should provide background
what I'm trying to do.

The purpose of the script is to look through a team calendar (in a shared
Exchange mailbox) every day and report on any events for the current day
through current day + n days. The script adds each event to a message body
string and then sends an e-mail to the team, showing all the relevant
calendar items within the date range.

As it stands, if there is a 3-day event that spans Mon, Tue, and Wed, the
script only recognizes the event when run on Monday. From what I've been
able to determine, the reason for this is because the 3-day event only has
one entry for it in the calendar, and since the entry has a start date of
Monday, that's the only date that the script would see the all day event. So
when the script runs on Monday, it will show the event, and correctly shows
that it spans Mon - Wed. But on Tue and Wed, the script does not see the
3-day event at all. The reason seems to stem from the fact that the script
is looking for all items that are on Tue and Wed, and since the 3-day event
is tied to Monday's date, the script won't see it on Tue and Wed.

I could put logic in to check for the range of the all day event, and if it
includes the current date, then make a note of it in the e-mail. BUT, what
if the all day event spans a week, or 2 weeks, or a month? I don't want to
have my script check so many dates just to compensate for this issue with
the all day events. Unless there's another, more efficient way to work
around this, I might have to do that. It's ugly, but that might be my only
option.
--
Regards,
M
MCTS, MCSA

"JP" <***@earthlink.net> wrote in message news:b20851e8-5cd4-4c13-a618-***@c10g2000vbr.googlegroups.com...
Gotcha, I thought you were setting them up on your own computer that
way.

Are you trying to calculate how many days the event lasts?

Couldn't your script grab the start date/time and end date/time and
calculate how many days it's for?

Or am I missing something.

--JP
Post by M
To clarify, my script is only reading events that were posted manually by
users. If a user has a 3-day vacation, then the user would make a 3-day all
day event for that, because that's the natural thing to do and makes sense.
I can't tell the user to create 3 individual events just to get my code to
work. I posted the code in reply to Sue's reply.
--
Regards,
M
Create three separate all-day events instead? Or are you creating ONE
all-day event and telling Outlook that it runs from Monday through
Wednesday? You might want to post your code.
--JP
Post by M
I created a VBS script using CDO to look at all the items in a particular
Exchange mailbox calendar between a specific date range. I've almost got
eveverything working, but one thing I noticed is that all day events which
span several days actually consists of only a single entry in the calendar.
Outlook is smart enough to show the event spanning several days, but it only
stores the entry on the start date. In case my explanation wasn't clear,
I have an all day event that spans Monday, Tuesday, and Wednesday.
When viewed in Outlook, I can see the event spanning all three days.
When my script runs and looks for items for that entire week, the script
only sees one entry for the 3-day event, and that's on Monday. When the
script looks at Tuesday and Wednesday, it doesn't see the event at all.
It seems that this issue is by design, and seems logical to me, so I
understand why this is happening. Is there any way to work around this, so
that when my script looks at Tuesday and Wednesday, it would see the 3-day
event?
Thank you.
--
Regards,
M
MCTS, MCSA- Hide quoted text -
- Show quoted text -
Loading...