Code for the topic :E_ACCESSDENIED error when logging into a CDO session to access Global Address Bo

D

deepu

Hi,
Please find the code am trying.
Regards,
deepak

<html>
<head>
<meta name="GENERATOR" content="YesSoftware CodeCharge v.2.0.3 /
Templates.ccp build 10/17/2001">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"><link rel="stylesheet" href="Site.css"
type="text/css">
<link rel="stylesheet" href="Footer.css" type="text/css"></head>
<script src="GlobalAddressBook.vbs" language="VBScript"
type="text/vbscript"></script>
<body class="PageBODY">
<table>
<tr>
<td valign="top">
<!--BeginFormUser-->
<form method="POST" action="{FileName}" name="User">
<table class="FormTABLE">

<!--
<tr>
<td class="FieldCaptionTD"><font
class="FieldCaptionFONT">Login</font></td>
<td class="DataTD"><input type="text" name="login" maxlength="15"
value="{login}" size="15"></td>
</tr>

<tr>
<td class="FieldCaptionTD"><font
class="FieldCaptionFONT">Password</font></td>
<td class="DataTD"><input type="password" name="pass"
maxlength="15" value="{pass}" size="15"></td>
</tr>
-->

<tr>
<td class="FieldCaptionTD"><font
class="FieldCaptionFONT">Name</font></td>
<td class="DataTD"><input type="text" name="user_name"
maxlength="30" value="{user_name}" size="18">
<input type="submit" name="globalAddressBook" value="Browse"
value="Click">
<SCRIPT FOR="globalAddressBook" EVENT="onClick"
LANGUAGE="VBScript">
'For all the API for programming with Outlook
http://msdn.microsoft.com/library/d...html/591200b7-e0d4-408d-b0f1-2fca07c5a4e6.asp
Const cdoE_USER_CANCEL = &H80040113
' start CDO session
Set objSession = CreateObject("MAPI.Session")
Call objSession.Logon ("Outlook")
On Error Resume Next
Set colCDORecips = objSession.AddressBook(, _
"Pick a Name", , , 1, _
"My Choice") 'Returns a Reciepients Collection
Object
If Err = 0 Then
If colCDORecips.Count <> 1 Then
MsgBox "Please choose exactly 1 name.", , _
"Chose One Name"
Else
Set recepObject = colCDORecips.Item(1) 'Returns an object of type
Recepient
isPDL = recepObject.AddressEntry.DisplayType 'Returns the type of
the reciepient address
If isPDL = 1 then 'DisplayType is set to CdoDistList{1} so its a
Public Distribution List
Set objAddrEntriesColl = recepObject.AddressEntry.Members 'Returns
a collection which has all the members
numberOfMembers = objAddrEntriesColl.Count 'Gets the count
For i=1 to numberOfMembers
Set addressEntryObject = objAddrEntriesColl.Item(i) 'Each is a
address entry object
For each objField in addressEntryObject.Fields
If (instr(objField.value,"@domain.com")) Then
Set mailId = objField.value
MsgBox "Correct Mail-id:" &objField.value
End If
Next
Next
ElseIf isPDL = 0 then 'DisplayType is set to CdoUser{0} so its a
Its local messenging user
Set addressEntryObj = colCDORecips.Item(1).AddressEntry
address = addressEntryObj.Address

'MsgBox "The Entry selected is :"
&colCDORecips.Item(1).AddressEntry.Address
For each objField in addressEntryObj.Fields
If (instr(objField.value,"@domain.com")) Then
Set mailId = objField.value
MsgBox "Correct Mail-id:" &objField.value
End If
Next
Else
MsgBox "The selected entry is either not a local user/Public
Distribution List {PDL}. "
End if
If Err = 287 Then
' security block triggered
MsgBox "Outlook cannot return " & _
"a name, because " & _
"you clicked No on the " & _
"e-mail address access " & _
"dialog. You need to try " & _
"again and click Yes " & _
"this time.", , _
"E-mail Address Access"
End If
End If
ElseIf Err = cdoE_USER_CANCEL Then
' user canceled the address book dialog -
' do nothing or provide a message to user
End If
' release objects
objSession.Logoff
Set colCDORecips = Nothing
Set objSession = Nothing
</SCRIPT>
</td>

</tr>
<tr>
<td class="FieldCaptionTD"><font
class="FieldCaptionFONT">Email</font></td>
<td class="DataTD"><input type="text" name="email" maxlength="30"
value="{email}" size="30"></td>
</tr>


<tr>
<td colspan="2" align="right">
<!-- *** Buttons *** -->

<!--BeginUserInsert-->
<input type="hidden" value="insert" name="FormAction">
<input type="submit" value="Add"
onclick="document.User.FormAction.value = 'insert';">
<!--EndUserInsert-->

<!--BeginUserEdit-->
<input type="hidden" value="update" name="FormAction"/>

<!--BeginUserUpdate-->
<input type="submit" value="Update"
onclick="document.User.FormAction.value = 'update';"/>
<!--EndUserUpdate-->

<!--BeginUserDelete-->
<input type="submit" value="Delete"
onclick="document.User.FormAction.value = 'delete';"/>
<!--EndUserDelete-->

<!--EndUserEdit-->

<input type="hidden" name="FormName" value="User"/>

<input type="hidden" name="PK_user_id" value="{PK_user_id}"/>
<input type="hidden" name="user_id" value="{user_id}"/>
</td>
</tr>
</table>
</form>
<!--EndFormUser-->
<SCRIPT Language="JavaScript">
if (document.forms["User"])
document.User.onsubmit=delconf;
function delconf() {
if (document.User.FormAction.value == 'delete')
return confirm('Delete record?');
}
</SCRIPT>
</td>
</tr>
</table>


</body>
</html>
 

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