Outlook invalid user resolved

Alan Searle 1 Reputation point
2021-11-01T18:04:12.443+00:00

Hallo All,

I need to read the entries for a number of users from shared calendars. For this, I am using the command ...

Set objOwner=oNS.CreateRecipient(strAnEmail)
objOwner.Resolve
if objOwner.Resolved Then
... etc.

This works fine and I can read in the entries for the users I need. But somehow duplicate entries are being read in for users which are invalid for the time period I am querying.

I use this filter to set the period I am reading ...

strFilter = "[Start] >='" & strPeriodFrom & "' AND [End] < '" & strPeriodUntil & "'"

... which works fine and retrieves the period I need.

But the problem is that duplicates of valid entries during that time period appear for users who have no entries in that period.

So my question is how do I keep them out? What am I doing wrong?

Can I maybe add a "User" or "Email" filter to strFilter (i.e. my time period)?

This is a big irritation because surely the time-filter should keep those entries out. And indeed the entries apply to another use and are valid for that (other) user but not for the unwanted one.

Any ideas?

Or maybe someone can point me towards a good snippet of code which does this?

Many thanks,
Alan Searle
Cologne, Germany

Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,885 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Alan Searle 1 Reputation point
    2021-11-02T20:57:30.667+00:00

    Hallo Viorel-1,

    I start off thus ...

    Set objOwner = oNS.CreateRecipient("name@mydomain.com")
    objOwner.resolve

    if objOwner.Resolved Then

    Set oAppointments = oNS.GetSharedDefaultFolder(objOwner, olFolderCalendar)

    Then I apply the filter string ...

    strFilter = "[Start] >='" & strPeriodFrom & "' AND [End] < '" & strPeriodUntil & "'"

    ... with this syntax ...

    Set oFilterAppointments = oAppointments.Items.Restrict(sFilter)

    Which seems to work for the time-period required but also returns entries (duplicates of valid entries for relevant users) assigned to other users who had no appointments in that period.

    This is weird because surely objOwner in the "Set oAppointments=" line should limit the items to only the required user?

    Yours,
    Alan


  2. Alan Searle 1 Reputation point
    2021-11-03T14:11:41.45+00:00

    Hallo Viorel-1,

    Yes, indeed, that is what I would like to do.

    So is there syntax for adding the email (i.e. ID) of the user whose calendar entries I am trying to retrieve to the filter (currently on the time-period)?

    I am bemused that the declaration ...

    Set oAppointments = oNS.GetSharedDefaultFolder(objOwner, olFolderCalendar)

    ... didn't limit the retrieval to that user (i.e. objOwner).

    Or does the command "GetSharedDefaultFolder" involve getting that folder also for users/emails which "share" that folder?

    Many thanks for your help.

    Yours,
    Alan

    0 comments No comments