yellowartist
IS-IT--Management
I have about 400 Contact cards I need to create. I am running into an error when creating the mailNickname. I want it to be a phone number however I get the following error.
[highlight]
Line: 40
Char: 4
Error: Unspecified error
Code: 80004005
Source: (null)
[/highlight]
It will work when I do (PhoneNumber@phonecarrier.com).
Here is the Code:
[highlight]
Line: 40
Char: 4
Error: Unspecified error
Code: 80004005
Source: (null)
[/highlight]
It will work when I do (PhoneNumber@phonecarrier.com).
Here is the Code:
Code:
' ContactExcel .vbs
' Purpose VBScript to create contacts from a list on names in Excel
' --------------------------------------------------------------'
Option Explicit
Dim objRootLDAP, objContainer, objContact, objExcel, objSheet
Dim strOU, strContactName, strPathExcel, strEmail
Dim intRow, strYourDescription, strFirst, strLast, strAlias, StrDisplay
' Set string variables
' Note: Assume an OU called suppliers exists.
strOU = "domain.com/OU=_ADC ," ' Note the comma
strPathExcel = "z:\Scripts\contacts.xls"
strYourDescription = "Guy's Contact"
intRow = 2 ' Row 1 contains headings
' Section to bind to Active Directory
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & objRootLDAP.Get("DefaultNamingContext"))
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSheet = objExcel.Workbooks.Open(strPathExcel)
' Here is the loop that cycles through the cells
Do Until (objExcel.Cells(intRow,1).Value) = ""
strContactName = objExcel.Cells(intRow, 1).Value
strAlias = objExcel.cells(intRow, 2).Value
strEmail = objExcel.cells(intRow, 3).Value
strFirst = objExcel.cells(intRow, 4).Value
strLast = objExcel.cells(intRow, 5).Value
StrDisplay = objExcel.cells(intRow, 6).Value
' 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 "mailNickname", strAlias
objContact.Put "proxyAddresses", "SMTP:" & strEmail
objContact.Put "targetAddress", "smtp:" & strEmail
objContact.SetInfo
intRow = intRow + 1
Loop
Wscript.Echo "Done"
objExcel.Quit
WScript.Quit