RE: Incorrect Start Dates for Shared Recurring Appointments

From: Karen Anderson (karenandmsonline_at_microsoft.com)
Date: 10/01/04


Date: Fri, 01 Oct 2004 22:50:52 GMT

Hi,

My name is Karen Anderson and I will be working with you on your newsgroup
issue from here. I am a member of Developer Support for Messaging at
Microsoft.

I have reviewed the thread that has occurred on this issue and I apologize
if I need to back up and rehash items which you may have already discussed.
 I need to do this to ensure that I have an accurate description of the
behavior you are experiencing.

I am aware that you have looked at the article indicating that you must
declare the Outlook::AppointmentItem as an object and use late binding in
order to return the correct date of the recurring items.

OL2000: Incorrect Start Dates for Shared Recurring Appointments (232534)
http://support.microsoft.com/?id=232534

I have tested this information and it is still true for Outlook 2003. Here
are the steps that I have performed to test this issue:
1 - Logon to Outlook as User1
2 - Create a recurring appointment starting today, 10/1 at 3pm PDT and
recurring for 3 days (10/1-10/3).
3 - Add User2 to the permissions tab of the Calendar. Set the permissions
to None.
4 - Logon to Outlook as User2 and run the following code. The code fails
as I do not have access to User1's Calendar.
5 - Logon to Outlook as User1 and change User2's permissions to Reviewer.
6 - Logon to Outlook as User2 and run the following code. The result is:
10/1/2004 3:00:00 PM
10/2/2004 3:00:00 PM
10/3/2004 3:00:00 PM

7 - Change the code to use early binding and the results is:
10/1/2004 3:00:00 PM
10/1/2004 3:00:00 PM
10/1/2004 3:00:00 PM

===========================================

I am not getting a repro of the problem you indicate about the dates not
being correct. Can you run the code that I am sending and let me know the
results?

You also mention the following other issues:

- When using GetFolderFromID, you receive an error. To use
GetFolderFromID, the folder must be loaded within the profile and cannot be
a shared folder. If you are attempting to access a shared folder which you
do not have logon permissions to, you will get an error. Most likely, you
are getting the error "Could not open the item. Try again." or "Run-time
error '-1698562039 (9ac20009)'. This is because the folder is not within
the profile which is necessary to use this method. This is why the
GetSharedDefaultFolder exists.

Using GetFolderFromID will also fail if you attempt to access a Public
Folder and the Public Folder list has not been "loaded" or expanded during
the current session. Outlook will not be able to directly access the
folder until the tree is expanded. To work around this, you call traverse
the folders to get to the folder you are looking for.

- When you use GetSharedDefaultFolder, it adds the folder in the "Other
Calendars" listing of the Calendar folder view. This is a result of using
this method and there is no way to work around it. It was considered a
feature as many people wanted past calendars that they queried to be
available here without them having to add them back each time.
Unfortunately, the opposite is what you are looking for and the bad news is
that you cannot prohibit this from occurring when calling this method.

' ============================ BEGIN SAMPLE CODE
============================
' WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS MESSAGE IS AT YOUR
OWN RISK.
' Microsoft provides this code "as is" without warranty of any kind, either
expressed or implied.
Sub TestRecur()
    Dim Recip As Outlook.recipient
    Dim fldr As Outlook.MAPIFolder
    Dim CalItems As Outlook.items
    'Dim AppItem As Outlook.AppointmentItem
    Dim AppItem As Object
    
    Set Recip = Application.session.CreateRecipient("test6")
    Recip.Resolve
    Set fldr = Application.session.GetSharedDefaultFolder(Recip,
olFolderCalendar)
    
    Set CalItems = fldr.items
    CalItems.Sort "[Start]"
    CalItems.IncludeRecurrences = True
    Set AppItem = CalItems.Find(" ([Start] >= '" & Date & "')")
    
    While Not AppItem Is Nothing
        Debug.Print AppItem.Start
        Set AppItem = CalItems.FindNext
    Wend
End Sub
' ============================ END SAMPLE CODE ============================

Karen Anderson
Microsoft, Developer Support Engineer - Windows Messaging / Outlook

Please do not send email directly to this alias. This alias is for
newsgroup purposes only.

Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights.
--------------------
| Thread-Topic: Incorrect Start Dates for Shared Recurring Appointments
| thread-index: AcSiPLKljppdXVyaTiiDwgwrE1Tydw==
| X-WBNR-Posting-Host: 195.41.215.252
| From: =?Utf-8?B?SmVzcGVy?= <jepses@newsgroups.nospam>
| Subject: Incorrect Start Dates for Shared Recurring Appointments
| Date: Fri, 24 Sep 2004 06:45:05 -0700
| Lines: 96
| Message-ID: <C0DE710B-65A1-4346-B949-2933B17F0DFB@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.office.developer.automation
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.office.developer.automation:9658
| X-Tomcat-NG: microsoft.public.office.developer.automation
|
| Hi
|
| I have pretty much the problem described in this article :
| http://support.microsoft.com/default.aspx?scid=kb;en-us;232534 except
that my
| problem is I using outlook 2003, and the suggestion on make late binding
to
| appointment item doesn't resolve the problem. What does solve the
problem is
| give full rights in the item folder to the user running my program, but
that
| is not the solution in will implement.
|
| My code look like this:
|
| My input is
| Startdate : The startdate from which to return appointments
| Lookaheaddays : the number of days to return appointments for
| calenders : currently a folderid (later maybe an array of folderid's)
|
| Public Function GetAppointments(Startdate, LookAheadDays, Calenders) As
| Variant
| Dim count
| Dim MyItems
| Dim Appointments As Collection
| Dim AppItem As Object 'Outlook.AppointmentItem
| Dim UserID As String
| 'Dim UserObj As Outlook.Recipient
| Dim MyFolder
|
| MaxTime = DateSerial(DatePart("yyyy", Startdate), DatePart("m",
| Startdate), DatePart("d", Startdate) + LookAheadDays)
|
| If Left(Calenders, 4) = "USER" Then
| UserID = Mid(Calenders, 6)
| If UCase(UserID) = "SELF" Then
| Set MyFolder = NameSpace.GetDefaultFolder(9)
| Else
| Set UserObj = NameSpace.CreateRecipient(UserID)
| UserObj.Resolve
| If UserObj.Resolved Then
| Set MyFolder = NameSpace.GetSharedDefaultFolder(UserObj,
| olFolderCalendar)
| Else
| Set MyFolder = Nothing
| End If
| End If
| Else
| 'Set MyFolder = NameSpace.GetFolderFromID(Calenders)
| Set MyFolder = FindFolderById(Calenders)
| End If
| If Not MyFolder Is Nothing Then
| Set Appointments = New Collection
| Set MyItems = MyFolder.Items
| MyItems.Sort "[Start]", False
| MyItems.IncludeRecurrences = True
| Set AppItem = MyItems.Find(" ([Start] >= '" & CStr(DateAdd("d",
-1,
| Startdate)) & "')")
| While Not (AppItem Is Nothing)
| DoEvents
| If (AppItem.Start < MaxTime) Then
| If (AppItem.Start >= Startdate) Then
| Appointments.Add AppItem
| End If
| Set AppItem = MyItems.FindNext
| Else
| Set AppItem = Nothing
| End If
| Wend
| Else
| Set Appointments = Nothing
| End If
| Set AppItem = Nothing
| Set MyItems = Nothing
| Set MyFolder = Nothing
| Set GetAppointments = Appointments
| End Function
|
| The Recurring Appointments are included in below statement,
| Set AppItem = MyItems.Find(" ([Start] >= '" & CStr(DateAdd("d",
-1,
| Startdate)) & "')")
|
| even that the stated startdato is before the searched startdate, so the
| return of appointmest is actually right, but it contains the data of the
| first (master) appointment.
|
| What to do???
|
|
| Another problem is when executing the following (commented in above code
| bacuase of workaround)
| Set MyFolder = NameSpace.GetFolderFromID(SomeFolderIdOfSharedFolder)
| result sometimes in outlook doesn't return a result og returns an outlook
| error.
| It is even worse when the folderid is of a folder bellonging to another
| person, and if the folder is not part of the folderlist in outlook.
|
| In 2003 when open an another users calender by
| NameSpace.GetSharedDefaultFolder(UserObj, olFolderCalendar) the folder is
| "mounted" in the 2003 panel, which is not always wanted.
|



Relevant Pages

  • Re: HTML Item properties vs. Regular item properties
    ... Why would Outlook record different times for the HTTP ... and the default folder? ... Dim app As Outlook.Application ... "Dmitry Streblechenko" wrote: ...
    (microsoft.public.outlook.program_vba)
  • Re: HTML Item properties vs. Regular item properties
    ... I don't use the MSN provider, but AFAIK the date in the default store's is ... OutlookSpy - Outlook, CDO ... as well as the Sent Items folder on the MSN server. ... Dim app As Outlook.Application ...
    (microsoft.public.outlook.program_vba)
  • Re: Copying contents of a folder
    ... Viele Gruesse / Best regards ... Keep your Outlook categories organized! ... Dim olApp As New Outlook.Application ... At the time it is being run, the Contacts Folder has the 330 odd members ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Saving attachments to folder from public folder
    ... If it's running in the Outlook VBA project do not instantiate a new Outlook.Application object, use the intrinsic Application object instead. ... You'd need to select the public folder and then select the items where you want to work with the attachments. ... Dim oFolder As Outlook.MAPIFolder ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: HTML Item properties vs. Regular item properties
    ... Why would Outlook record different times for the HTTP folder ... Dim app As Outlook.Application ... Set itemCopy = item1.Copy ... OutlookSpy - Outlook, CDO ...
    (microsoft.public.outlook.program_vba)