question

AlanSearle-8708 avatar image
0 Votes"
AlanSearle-8708 asked AlanSearle-8708 answered

Outlook invalid user resolved

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

office-outlook-itprooffice-vba-dev
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AlanSearle-8708 ,

Welcome to our forum!

Please kindly understand under Outlook tag, we mainly focus on general issues about Outlook desktop client. Considering that your issue may be more related to development, I would add "office-vba-dev" tag under your post to solve it better. Thanks for your understanding and hope your issue would be resolved soon.

0 Votes 0 ·

How do you set the filter in your code?


0 Votes 0 ·
AlanSearle-8708 avatar image
0 Votes"
AlanSearle-8708 answered Viorel-1 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


If the wrong entries are included too when you do not set the filter, then you should extend the filter to specify all of required criteria, I think.


0 Votes 0 ·
AlanSearle-8708 avatar image
0 Votes"
AlanSearle-8708 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.