Recipient.Resolve without security warning

S

Stephan Steiner

Hi

As the title says, I'm trying to find a way to call Recipient.Resolve
without the annoying security warning. I have already checked out Outlook
Redemption, but while Redemption knows the Recpient object, it is only
exposed as part of an Item, and thus without any possibility for resolving.

I suspect this is still somehow possible, after all, Outlook's address book
is a primary source of information for all those worms we've seen over the
past 1.5 years (not that I'm writing anything like it of course, I'm trying
to pop up the calendar of a person if a phone call is diverted to the
central switchboard because nobody picked up.. so what my app has to do is
hook into TAPI, catch the appropriate events, look up the telephone number
in an address book resulting in the name of the person, then create a
recipient object from that info, and open the recipients' shared calendar).

I've seen it can be done using Outlook security templates, but getting
exchange admins to cooperate can be impossible some time, plus we're
currently using a rather old exchange version (v5.5) which to my knowledge
doesn't support security templates (correct me if I'm wrong). So, is there
any other way?

Stephan
 
K

Ken Slovak - [MVP - Outlook]

Exchange 5.5 does support the Exchange security form. I've used it with my
Exchange 5.5 server for both the Outlook 2000 and 2002 versions of the form.

You certainly can resolve a recipient using Redemption. I do it all the
time. Once you have a Redemption SafeRecipient object you just use its
Resolve method. There's also a .Resolved property to check. SafeRecipients
has a ResolveAll method.
 
S

Stephan Steiner

Ken
Exchange 5.5 does support the Exchange security form. I've used it with my
Exchange 5.5 server for both the Outlook 2000 and 2002 versions of the form.

You certainly can resolve a recipient using Redemption. I do it all the
time. Once you have a Redemption SafeRecipient object you just use its
Resolve method. There's also a .Resolved property to check. SafeRecipients
has a ResolveAll method.

Would you mind sharing some example code? It is my understanding that you
have to create the appropriate OOM object, create the corresponding
Redemption object, then set redemptionobject.item = OOM object. However,
there is no SafeRecipient.Item so I don't know how I link my SafeRecipient
object to my OOM Recipient. Furthermore, I cannot create an instance of
SafeRecipientClass directly, its constructor seems to be private.

Regards
Stephan
 
K

Ken Slovak - [MVP - Outlook]

Sure, it's pretty simple:

Dim oMail As Outlook.MailItem
Dim safMail As Redemption.SafeMailItem
Dim safRecips As Redemption.SafeRecipients
Dim safRecip As Redemption.SafeRecipient

'assume here that mail item has been created and populated with properties
' such as .Body and .Subject
Set safMail = CreateObject("Redemption.SafeMailItem")
safMail.Item = oMail
Set safRecipients = safMail.Recipients
Set safRecipient = safRecipients.Add("someaddress in SMTP format")
safRecipient.Resolve
If safRecipient.Resolved Then
'ok
Else
'not resolved
End If
'and so on
 
S

Stephan Steiner

Ken

Thanks for the code. I've managed to get it working in C#. Then I found out
that I didn't even have to resolve the address in order to be able to open a
user's shared folder(s).

Yet, I suppose it's better to resolve and be sure things actually work out
as desired. I don't suppose there's a way to go back from a SafeRecipient to
a Recipient is there? And are there any inheritent disadvantages using a non
resolved Recipient?

Stephan
 
K

Ken Slovak - [MVP - Outlook]

Please post some of the preceding thread in your messages, it makes it very
hard to follow when you don't.

A SafeRecipient is the underlying Outlook or CDO Recipient, except the
restricted methods and properties are not restricted in the safe object. Any
method or property that you use on a SafeRecipient that isn't exposed in the
Redemption object model is passed to the underlying Outlook or CDO Recipient
object. That is the same for any Redemption object.

If a recipient is added using Redemption's Add method on the SafeRecipients
collection the method does return a resolved SafeRecipient if you add it
using an SMTP address (or an Exchange distinguished name). However if you
use the alternative of using a name ("Joe Beerkeg") then it may or may not
be resolved depending on whether that name resolves to some email address.

Using an unresolved recipient that can't be resolved just means your code
will fail from that point on. So if you can live with that you don't have to
resolve or check resolution for a recipient object. If not then always
resolve and/or check for a resolved recipient before you try to use it
anywhere.
 
S

Stephan Steiner

Ken
A SafeRecipient is the underlying Outlook or CDO Recipient, except the
restricted methods and properties are not restricted in the safe object. Any
method or property that you use on a SafeRecipient that isn't exposed in the
Redemption object model is passed to the underlying Outlook or CDO Recipient
object. That is the same for any Redemption object.

And what about those that are exposed? Recipient.Add is exposed. I'd like to
add a SafeRecipient to a SafeRecipients collection, resolve it, and if it
can be resolved, create a resolved Recipient (without triggering Outlook's
safety measures). I know I could just resolve on the saferecipient, and
using the same name/address, I can create a regular Outlook.Recipient, of
which I know that it can be resolved (since I've resolved the name/address
using the SafeRecipient), but where I haven't actually called the
Recipient.Resolve method.

I hope this makes sense.

Regards
Stephan
 
K

Ken Slovak - [MVP - Outlook]

Any property or method that's in a Redemption item can certainly be used and
if it's there it's usually because the Outlook item restricts it or it's not
there in the Outlook object model.

The Object Browser is a very useful tool. Looking at SafeRecipients.Add (or
..AddEx) shows that the return value is a SafeRecipient. So using that method
gives you a SafeRecipient. Is that what you were asking? If not try to
rephrase the question.
 
S

Stephan Steiner

Ken
Any property or method that's in a Redemption item can certainly be used and
if it's there it's usually because the Outlook item restricts it or it's not
there in the Outlook object model.

I guess I have to rephrase. Here's a snippet from my code:

Outlook.Recipient rec = ns.CreateRecipient("Lastname, Firstname");

.....

Outlook.MailItemClass mail =
(Outlook.MailItemClass)applicationObject.CreateItem(0);
mail.Body = "some text";
mail.Subject = "some subject";
Redemption.SafeRecipients sr = null;
Redemption.SafeMailItemClass smail = new Redemption.SafeMailItemClass();
smail.Item = mail;
sr = smail.Recipients;
Redemption.SafeRecipient sr2 = sr.Add("LastName, FirstName");
valid = sr2.Resolve(false);

.....

ns = applicationObject.GetNamespace("MAPI");
folder = ns.GetSharedDefaultFolder(rec,
Outlook.OlDefaultFolders.olFolderCalendar);

Basically, I want the rec for my last line to be a resolved
Outlook.Recipient. sr2 is my resolved SafeRecipient.. so rather than to
create a new Outlook.Recipient (my first line of code), I'd like to use the
SafeRecipient sr2 instead (or somehow convert sr2 into a resolved
Outlook.Recipient).

I hope this is easier to follow than my previous message.

Regards
Stephan
 
K

Ken Slovak - [MVP - Outlook]

As I said before you don't have to create an Outlook Recipient at all here.
If you have a SafeMailItem you can get its Recipients collection. That gives
you a SafeRecipients collection. Then you can use that collection's Add or
AddEx methods to add recipients, each of which is a SafeRecipient. Then you
can use the SafeRecipient.Resolve method and/or test for
SafeRecipient.Resolved.
 

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