[Redemption] Failed To Resolve SafeRecipients In SafeAppointmentItem

M

Michael Zino

Hello,

I am developing an Outlook addin using Redemption.
I am trying to add recipients to the Outlook AppointmentItem as follows:

Dim oSafeAppointment As Object

Set oSafeAppointment = CreateObject("Redemption.SafeAppointmentItem")
oSafeAppointment.Item = m_oAppointmentItem
'Note: m_oAppointmentItem was retrieved from OOM

'The following is not working; "Resource1" and "Resource2" are being added
to the appointment but can't be resolved
oSafeAppointment.Resources = "Resource1;Resource2"
oSafeAppointment.Recipients.ResolveAll

'The following is not working as well
Set oSafeRecipient = oSafeAppointment.Recipients.Add("Resource1")
oSafeRecipient.Type = olResource
oSafeRecipient.Resolve 'The problem is that "Resource1" isn't being added to
the appointment

"Resource1" and "Resource2 exist and are being resolved automatically when
they are being added manually through the Outlook UI or when using the
following code:

m_oAppointmentItem.Resources = "Resource1;Resource2"
m_oAppointmentItem.Recipients.ResolveAll 'succeeded with security alerts

Additionally, when I am using MAPIUtils and creating
SafeRecipient--"Resource1" is resolved. But it can't help me, and I wrote it
just to make sure that the problem is not Exchange related:

Dim oSafeRecipient As SafeRecipient
Dim oUtils As Object

Set oUtils = CreateObject("Redemption.MAPIUtils")
Set oSafeRecipient = oUtils.CreateRecipient("Resource1")
If oSafeRecipient.Resolved = True Then
Debug.Print oSafeRecipient.Name & "Resolved=True; Address=" &
oSafeRecipient.Address
End If

Please advise.

Regards,
Michael Zino
 
S

Sue Mosher [MVP-Outlook]

You must resolve the recipient before you can set the Type. Does this work
better:

Set oSafeRecipient = oSafeAppointment.Recipients.Add("Resource1")
oSafeRecipient.Resolve
oSafeRecipient.Type = olResource
 
M

Michael Zino

Hello Sue,

Thank's for your help.

As I commented in my previous post, using this code doesn't add the resource
to the appointment at all.

However, I changed the order in which I assigned the type of the recipient
as you suggested, but still got nothing.
The resource is not being added to the appointment (SafeAppointmentItem).

The only way I succeeded to add the resource to the appointment (when using
Redemption) is by using the following code:

m_oSafeAppointment.Resources = "Resource1"
m_oSafeAppointment.Recipients.ResolveAll

But when using this concept, the resource (or the recipient) is not being
resolved, although I explicitly invoked the ResolveAll method.

Thanks,
Michael Zino


You must resolve the recipient before you can set the Type. Does this work
better:

Set oSafeRecipient = oSafeAppointment.Recipients.Add("Resource1")
oSafeRecipient.Resolve
oSafeRecipient.Type = olResource

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

If you look in the Object Browser at the Redemption
SafeAppointmentItem you will see that .Resources is a read-only
string, so you can't directly set that property.

Have you tried setting the recipients you are adding and want to be
resources as Bcc recipients? According to the Help resources are added
as Bcc recipients.
 
D

Dmitry Streblechenko \(MVP\)

How do you know that the resources cannot be resolved? After resolving, can
you access Recipient.Address and Recipient.EntryID properties? Note that
Outlook will not reflect in its UI any changes made through anything but the
Outlook Object Model until you completely dereference and reopen thne
object. Is m_oAppointmentItem displayed at the time your code is executed?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Michael Zino

Dear Dmitry,

After resolving, the Recipient.Address and Recipient.EntryID are both empty
strings.
I am sure that this is a resolving issue, as the added resource is not
underlined and there is no free / busy information.
If I am using Tools | Check Names, the resource is resolved.

My addin is manipulating the current AppointmentItem, which is currently
being displayed by the Outlook UI.

I tried to add SafeRecipient into the SafeRecipients collection of the
SafeAppointmentItem, and to completely dereference and reopen the object and
still the SafeRecipient wasn't added to the appointment item.

Additionally, I am wondering how I can access the SafeAppointmentItem's
Resources property, although it is read only property.
It seems that the only way of adding resources to the SafeAppointmentItem is
by using the Resources property, as other methods don't work at all.

Regards,
Michael Zino

How do you know that the resources cannot be resolved? After resolving, can
you access Recipient.Address and Recipient.EntryID properties? Note that
Outlook will not reflect in its UI any changes made through anything but the
Outlook Object Model until you completely dereference and reopen thne
object. Is m_oAppointmentItem displayed at the time your code is executed?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Michael Zino

Dear Ken,

The Class property of the Redemption's SafeRecipient is read-only as well.
However, I tried the following code:

Dim oSafeRecipient As Object
Set oSafeRecipient = m_oSafeAppointment.Recipients.Add("Resource1")
oSafeRecipient.Class = 3 ' BCC
oSafeRecipient.Resolve

And still, the recipient wasn't added to the AppointmentItem at all.
The only way, I succeeded to add the "non-resolved" recipient only by using
the Resources property.

Regards,
Michael Zino


If you look in the Object Browser at the Redemption
SafeAppointmentItem you will see that .Resources is a read-only
string, so you can't directly set that property.

Have you tried setting the recipients you are adding and want to be
resources as Bcc recipients? According to the Help resources are added
as Bcc recipients.
 
D

Dmitry Streblechenko \(MVP\)

Are you saying that the code below produces an empty address?

set Recip = SafeAppointment.Recipients.Add("resource1")
Recip.Resolve(TRUE)
MsgBox Recip.EntryID

Also note that SafeAppointmentItem.Resources is readonly because OOM blocks
reading of this property, writing is not blocked, hence you can set the
Resources property on the original OOM AppointmentItem without a security
prompt.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
M

Michael Zino

Yes indeed.
Additionally, the recipient itself won't be added to the underlying unsafe appointment item.
The only way I succeeded to add the recipient in a way that it will be reflected in the Outlook UI, is by using the Resources property.
But in this case, the added resource is not resolve.
Regards,
Michael Zino

Are you saying that the code below produces an empty address?

set Recip = SafeAppointment.Recipients.Add("resource1")
Recip.Resolve(TRUE)
MsgBox Recip.EntryID

Also note that SafeAppointmentItem.Resources is readonly because OOM blocks
reading of this property, writing is not blocked, hence you can set the
Resources property on the original OOM AppointmentItem without a security
prompt.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dmitry Streblechenko \(MVP\)

That's weird. Does it happen for *any* recipient name or just for some? What is the exact string that you pass to Recipients.Add?
Since you can create a valid recipient using MAPIUtils.CreateRecipient, you can simply copy the resolved properties to the Recipient returned by Recipients.Add:

Recip1.Fields(PR_ENTRYID) = Recip2..Fields(PR_ENTRYID)
etc for the PR_ADDRTYPE, PR_DISPLAY_NAME, PR_EMAIL_ADDRESS properties.

Another workaround is to add the recipients using AppointmentItem.Resources property, then programmatically execute (Tools|Check Names) since the inspector is displayed:

set btn = inspector.commandbars.FindControl(1, 361)
btn.Execute

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Yes indeed.
Additionally, the recipient itself won't be added to the underlying unsafe appointment item.
The only way I succeeded to add the recipient in a way that it will be reflected in the Outlook UI, is by using the Resources property.
But in this case, the added resource is not resolve.
Regards,
Michael Zino

Are you saying that the code below produces an empty address?

set Recip = SafeAppointment.Recipients.Add("resource1")
Recip.Resolve(TRUE)
MsgBox Recip.EntryID

Also note that SafeAppointmentItem.Resources is readonly because OOM blocks
reading of this property, writing is not blocked, hence you can set the
Resources property on the original OOM AppointmentItem without a security
prompt.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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

Top