1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| ' ExchContact.vbs
' Purpose VBScript to create a contact for Exchange 2003
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.4 - August 2005
' --------------------------------------------------------------'
Option Explicit
Dim objRootLDAP, objContainer, objContact, objExcel, objSheet
Dim strOU, strContactName, strPathExcel, strEmail, strProxy
Dim intRow, strYourDescription, strFirst, strLast, strMainDefault
Dim strMailbox, strNick
' Set string variables
' Note: Assume an OU called suppliers exists.
strOU = "OU=Suppliers ," ' Note the comma
strYourDescription = "Guy's Contact"
strMainDefault = "SMTP:acmeMain@acme.com"
strContactName="MrAcme"
strFirst = "Willy"
strLast= "Acme"
strProxy = "smtp:somebody@somewhereElse.com"
strEmail = "not@needed.org"
' ** Please investigate your Exchange Org, then change the next line **
strMailbox = "/o=GuyWorld/ou=First Administrative Group/cn=Recipients/cn="_
& strContactName
strNick = strContactName
' Section to bind to Active Directory
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU _
& objRootLDAP.Get("DefaultNamingContext"))
' Build the actual contacts.
Set objContact = objContainer.Create("Contact",_
"cn=" & strContactName)
objContact.Put "Mail", strEmail
objContact.Put "givenName", strFirst
objContact.Put "sn", strLast
objContact.Put "proxyAddresses", strProxy
objContact.Put "targetAddress", strMainDefault
objContact.Put "legacyExchangeDN", strMailbox
objContact.Put "mailNickname", strNick
objContact.SetInfo
WScript.Quit |
Partager