Please consider this working prototype of code using CDO.
What it does is finding the GAL, find some mailbox, change the phone and fax
number.

Const CdoPR_TRANSMITABLE_DISPLAY_NAME_A = &H3A20001E
Const CdoPR_PRIMARY_FAX_NUMBER = &H3A23001E
Set cdo = CreateObject("MAPI.Session")
cdo.Logon "", "", 0, 0, 0
Set addrlists = cdo.AddressLists
For C = 1 To addrlists.Count
    If addrlists.Item(C).Name = "Global Address List" Then
        Set gal = addrlists.Item(C)
        Exit For
    End If
Next
If gal Is Nothing Then
    MsgBox "Gal is nothing"
    Exit Sub
Else
    Set addrentries = gal.AddressEntries
    Set addrentry = addrentries.GetFirst
    Do While Not addrentry Is Nothing
        Set thefields = addrentry.Fields
        If thefields.Item(CdoPR_TRANSMITABLE_DISPLAY_NAME_A).Value =
"SomeAccount" Then
            Exit Do
        End If
        Set addrentry = addrentries.GetNext
    Loop
    thefields.Item(CdoPR_BUSINESS_TELEPHONE_NUMBER).Value = "123"
    thefields.Item(CdoPR_PRIMARY_FAX_NUMBER).Value = "456"
    addrentry.Update
End If

If instead I want to reset those fields (as in "delete the content of the
field from exchange admin) I thought I'd have to

thefields.Item(CdoPR_BUSINESS_TELEPHONE_NUMBER).Delete
thefields.Item(CdoPR_PRIMARY_FAX_NUMBER).Delete
addrentry.Update

This gets me a E_ACCESSDENIED on the .Delete . So I thought possibly those
fields can't be deleted (even if some freshly created mailbox won't have
them), so I'l reset the content since the type is a Variant/String:
thefields.Item(CdoPR_BUSINESS_TELEPHONE_NUMBER).Value = ""
thefields.Item(CdoPR_PRIMARY_FAX_NUMBER).Value = ""
addrentry.Update

This one gets me E_ACCESSDENIED at .Update (btw I definitively are using an
acconut with rights, I even tried using the service account).

Any idea what I'm doing wrong ? What's the correct way to empty those fields
?
Thanks
Heiko

-- 
-- PREVINET S.p.A.            [EMAIL PROTECTED]
-- Via Ferretto, 1            ph  x39-041-5907073
-- I-31021 Mogliano V.to (TV) fax x39-041-5907472
-- ITALY

_________________________________________________________________
List posting FAQ:       http://www.swinc.com/resource/exch_faq.htm
Archives:               http://www.swynk.com/sitesearch/search.asp
To unsubscribe:         mailto:[EMAIL PROTECTED]
Exchange List admin:    [EMAIL PROTECTED]

Reply via email to