Problem accessing other user TaskFolder

S

Scott Sommerfeldt

Greetings
I have a function that was adapted from one of Sue Moshers modules in her
Book "Microsoft Outlook Programming"
which works except that it displays a security dialog when it accesses the
recipient.
I want to modify this code to use redemption but..... all my attempts have
failed.
I am using Outlook 2000 in an Exchange 2000 enviroment.

Function GetOtherUserTaskFolder(UsersEmail As String) As MAPIFolder
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim strName As String
Dim objDummy As Outlook.TaskItem
Dim objRecip As Outlook.Recipient

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = Nothing

strName = UsersEmail
If strName <> "" Then
Set objDummy = objApp.CreateItem(olTaskItem)
Set objRecip = objDummy.Recipients.Add(strName)
objRecip.Resolve
If objRecip.Resolved = True Then
On Error Resume Next
Set objFolder = _
objNS.GetSharedDefaultFolder(objRecip, _
olFolderTasks)
On Error GoTo 0
Else
MsgBox "Could not find "
End If
End If
Set GetOtherUserTaskFolder = objFolder
Set objApp = Nothing
Set objNS = Nothing
Set objFolder = Nothing
End Function
 
S

Sue Mosher [MVP-Outlook]

Where's your Redemption code?

FWIW, you can try using the Application.CreateRecipient method to return a
valid Recipient object without running the Resolve method. I'm not convinced
it works in all cases, but if you have a unique name or alias for the other
mailbox, it's worth a try, since it avoids the security prompt that
Recipients.Add triggers.
 
D

Dmitry Streblechenko \(MVP\)

Also, when using Namespace.CreateRecipient, do *not* call
Recipient.Resolve - GetSharedDefaultFolder will still work, but there will
not be a security prompt.

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

Scott Sommerfeldt

Thanks
That worked.
I needed to first resolve a Recipient using Redemption because I did not
have the name , only the Email address and I need to avoid security prompts.
Here is the code that I used
objSafeDummy.Item = objDummy 'Assigning to Redemption
Set objSafeRecip = objSafeDummy.Recipients.Add(strName)
objSafeRecip.Resolve
If objSafeRecip.Resolved = True Then
On Error Resume Next
strName = objSafeRecip.Name
Set objRecip = objNS.CreateRecipient(strName)
Set objFolder = _
objNS.GetSharedDefaultFolder(objRecip, _
olFolderTasks)
.....................
Appreciate your assistance
Regards,
Scott Sommerfeldt
 
D

Dmitry Streblechenko \(MVP\)

Actually both Redemption and Outlook will resolve a name in the same way, in
this case there is no reason to use Redemption, you can go straight to
Namespace.CreateRecipient.

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