V
Vadivu
I am trying to get all the details from GAL through vbscript.When I use
Redemption,I can retrieve all the data from GAL as well as From my Local
directory.
The intension of this Program is compare the details of GAL with Local
directory, and if any details of GAL vary from Local directory that Local
directory item has to be updated in GAL.
Program:
wScript.Echo "MAPI Test"
Const AppPath = "D:\BODEV\"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const CdoPR_GIVEN_NAME = &H3A06001E
Const CdoPR_ENTRYID = &HFFF0102
Const CdoPR_DISPLAY_NAME =&H3001001E
Const CdoPR_TITLE = &H3A17001E
Const CdoPR_COMPANY_NAME =&H3A16001E
Const CdoPR_DEPARTMENT_NAME =&H3A18001E
Const CdoPR_OFFICE_LOCATION =&H3A19001E
Const CdoPR_BUSINESS_TELEPHONE_NUMBER =&H3A08001E
Const CdoPR_MOBILE_TELEPHONE_NUMBER = &H3A1C001E
Const CdoPR_STREET_ADDRESS =&H3A29001E
Const CdoPR_LOCALITY = &H3A27001E
Const CdoPR_POSTAL_CODE =&H3A2A001E
Const CdoPR_BUSINESS2_TELEPHONE_NUMBER =&H3A1B001E
Const CdoPR_PRIMARY_FAX_NUMBER =&H3A23001E
Const CdoPR_EMAIL=&H39FE001E
Dim filesys
Dim LogFilePath
Dim t3Entries
Dim galEntries
Set t3Entries = CreateObject("Scripting.Dictionary")
Sub Init
Call Init_LogFile()
End Sub
Sub Init_LogFile()
Dim CurDate, LogDate, AppName
dim filetxt, getname, path
AppName = "Test"
CurDate = Date
LogDate = Year(CurDate)
If Len(Month(CurDate)) = 1 Then
LogDate = LogDate & "0" & Month(CurDate)
Else
LogDate = LogDate & Month(CurDate)
End If
If Len(Day(CurDate)) = 1 Then
LogDate = LogDate & "0" & Day(CurDate)
Else
LogDate = LogDate & Day(CurDate)
End If
LogFilePath = AppPath & "Log\" & AppName & "_" & LogDate & ".log"
End Sub
Sub WriteLog(toWrite)
Dim LogFile
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
Set LogFile = filesys.OpenTextFile(LogFilePath,ForAppending,True)
LogFile.WriteLine toWrite
LogFile.close
Set LogFile = Nothing
End Sub
Sub cdofun()
Dim t3Item, isModified, t3EntryName
Set session = CreateObject("Redemption.RDOSession")
Dim t3DetailsByName
Set t3DetailsByName = CreateObject ("Scripting.Dictionary")
Session.Logon
MsgBox(session.currentuser & " " &"Logged In")
set AddrList = Session.AddressBook.AddressLists.Item("Global Address
List")
MsgBox "There are " & AddrList.AddressEntries.Count & " items in the
GAL"
Set objAddressEntries = AddrList.AddressEntries
int i=0
MsgBox(t3entries.count)
WriteLog("############## Compare GAL with T3-Dir #################")
For Each t3Item In t3entries.Keys
on error resume next
t3EntryName = t3Item
t3DetailsByName = t3entries(t3Item)
objAddressEntry = objAddressEntries.Item(t3EntryName)
Set isModified = 0
Set objAddressFields = objAddressEntry.Fields
MsgBox "From T3 " & t3EntryName
If Not objAddressFields is Nothing Then
WriteLog ("GAL Entries Before Comparision ")
MsgBox("Before Comparision")
MsgBox("Object Entry name " & objAddressEntry.Name)
WriteLog ("Name : " & " " & objAddressEntry.Name & "||" & " " &
"Manager :" & " " & objAddressEntry.Manager &"||" & " "&"JobTitle :" & " " &
objAddressEntry.Fields(CdoPR_TITLE) &"||" &" " & "Company :" & " " &
objAddressEntry.Fields(CdoPR_COMPANY_NAME) &"||" & " " &"Department :" & " "
& objAddressEntry.Fields(CdoPR_DEPARTMENT_NAME) &"||" & " " & "Office :" & "
" & objAddressEntry.Fields(CdoPR_OFFICE_LOCATION) &"||" & " "&"Phone :" & " "
& objAddressEntry.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER) &"||" & " "
&"Mobile :" & " " & objAddressEntry.Fields(CdoPR_MOBILE_TELEPHONE_NUMBER)
&"||" & " " & "Address :" & " " &
objAddressEntry.Fields(CdoPR_STREET_ADDRESS) &"||" & " "&"City :" & " " &
objAddressEntry.Fields(CdoPR_LOCALITY) &"||" & " "&"ZipCode :" & " " &
objAddressEntry.Fields(CdoPR_POSTAL_CODE) &"||" & " " &"Business Phone :" & "
" & objAddressEntry.Fields(CdoPR_BUSINESS2_TELEPHONE_NUMBER) &"||" & " "&"Fax
:" & " " & objAddressEntry.Fields(CdoPR_PRIMARY_FAX_NUMBER) &"||" & " "
&"E-Mail :" & " " & objAddressEntry.Fields(CdoPR_EMAIL))
End If
'Get the corresponding entry from t3 directory
t3DetailsByName = t3Entries(objAddressEntry.Name)
MsgBox "From GAL " & objAddressEntry.Fields (CdoPR_TITLE)
MsgBox "From T3 " & t3DetailsByName("Title")
If objAddressEntry.Fields (CdoPR_TITLE) <>
t3DetailsByName("Title") Then
isModified = 1
objAddressEntry.Fields(CdoPR_TITLE) = t3DetailsByName("Title")
ElseIf objAddressEntry.Fields (CdoPR_COMPANY_NAME) <>
t3DetailsByName("Company") Then
objAddressEntry.Fields (CdoPR_COMPANY_NAME) =
t3DetailsByName("Company")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_DEPARTMENT_NAME) <>
t3DetailsByName("Department")Then
objAddressEntry.Fields (CdoPR_DEPARTMENT_NAME) =
t3DetailsByName("Department")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) <>
t3DetailsByName("Office")Then
objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) =
t3DetailsByName("Office")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) <>
t3DetailsByName("Office")Then
objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) =
t3DetailsByName("Office")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_BUSINESS_TELEPHONE_NUMBER)
<> t3DetailsByName("Phone")Then
objAddressEntry.Fields (CdoPR_BUSINESS_TELEPHONE_NUMBER) =
t3DetailsByName("Phone")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_MOBILE_TELEPHONE_NUMBER) <>
t3DetailsByName("Mobile")Then
objAddressEntry.Fields (CdoPR_MOBILE_TELEPHONE_NUMBER) =
t3DetailsByName("Mobile")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_STREET_ADDRESS) <>
t3DetailsByName("Address")Then
objAddressEntry.Fields (CdoPR_STREET_ADDRESS) =
t3DetailsByName("Address")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_LOCALITY) <>
t3DetailsByName("City")Then
objAddressEntry.Fields (CdoPR_LOCALITY) = t3DetailsByName("City")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_POSTAL_CODE) <>
t3DetailsByName("ZipCode")Then
objAddressEntry.Fields (CdoPR_POSTAL_CODE) = t3DetailsByName("ZipCode")
isModified = 1
ElseIf objAddressEntry.Manager <> t3DetailsByName("Manager")Then
objAddressEntry.Manager = t3DetailsByName("Manager")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_BUSINESS2_TELEPHONE_NUMBER)
<> t3DetailsByName("BusinessPhone")Then
objAddressEntry.Fields (CdoPR_BUSINESS2_TELEPHONE_NUMBER) =
t3DetailsByName("BusinessPhone")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_PRIMARY_FAX_NUMBER) <>
t3DetailsByName("Fax")Then
objAddressEntry.Fields (CdoPR_PRIMARY_FAX_NUMBER) =
t3DetailsByName("Fax")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_EMAIL) <>
t3DetailsByName("Email")Then
objAddressEntry.Fields (CdoPR_EMAIL) = t3DetailsByName("Email")
isModified = 1
End If
If isModified=1 Then
WriteLog ("GAL Entries after update")
MsgBox( objAddressEntry.Name)
WriteLog ("Name : " & " " & objAddressEntry.Name & "||" & " " &
"Manager :" & " " & objAddressEntry.Manager &"||" & " "&"JobTitle :" & " " &
objAddressEntry.Fields(CdoPR_TITLE) &"||" &" " & "Company :" & " " &
objAddressEntry.Fields(CdoPR_COMPANY_NAME) &"||" & " " &"Department :" & " "
& objAddressEntry.Fields(CdoPR_DEPARTMENT_NAME) &"||" & " " & "Office :" & "
" & objAddressEntry.Fields(CdoPR_OFFICE_LOCATION) &"||" & " "&"Phone :" & " "
& objAddressEntry.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER) &"||" & " "
&"Mobile :" & " " & objAddressEntry.Fields(CdoPR_MOBILE_TELEPHONE_NUMBER)
&"||" & " " & "Address :" & " " &
objAddressEntry.Fields(CdoPR_STREET_ADDRESS) &"||" & " "&"City :" & " " &
objAddressEntry.Fields(CdoPR_LOCALITY) &"||" & " "&"ZipCode :" & " " &
objAddressEntry.Fields(CdoPR_POSTAL_CODE) &"||" & " " &"Business Phone :" & "
" & objAddressEntry.Fields(CdoPR_BUSINESS2_TELEPHONE_NUMBER) &"||" & " "&"Fax
:" & " " & objAddressEntry.Fields(CdoPR_PRIMARY_FAX_NUMBER) &"||" & " "
&"E-Mail :" & " " & objAddressEntry.Fields(CdoPR_EMAIL))
'Save the entry again to GAL with the updates
'Currently Saving the entry is not working because of access right
issues
'Uncomment the following line once that is fixed
'objAddressEntry.Save
Else
WriteLog ("GAL details for this employee matches with T3 details")
End If
Next
MsgBox("Comparison Over")
End Sub
Sub T3dir()
Dim objOL
Dim objNS 'Outlook namespace
Dim objExpl
Dim colCB
Dim objFindCBB
Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
MsgBox "From T3-Directory"
'display contacts as active folder
Set objExpl = objOL.ActiveExplorer
Set objPFldr = objNS.Folders.Item ("Public Folders")
Set objAPF = objPFldr.Folders.Item("All Public Folders")
'MsgBox objAPF.Name
Set objT3Dir = objAPF.Folders.Item("T3-Directory")
MsgBox objT3Dir.Name
MsgBox " There are " & objT3Dir.Items.Count & " " &"items in T3-Directory"
MsgBox objT3Dir.Display
set objItem =objT3Dir.Items
WriteLog(" ")
WriteLog("##################### T3-Directory Data ######################")
For each objItem in objT3Dir.Items
If Not objItem is Nothing Then
WriteLog ("Name :" & " " & objItem.FullName & "||" & "Job_Title :" & " "
& objItem.JobTitle & "||" & "Company :" & " " & objItem.CompanyName & "||" &
"Department :" & " " & objItem.Department & "||" & "Office :" & " " &
objItem.OfficeLocation & "||" & "Phone :" & " " &
objItem.BusinessTelephoneNumber & "||" & "Mobile :" & " " &
objItem.MobileTelephoneNumber & "||" & "Address :" & " " &
objItem.BusinessAddress & "||" & "City :" & " " & objItem.BusinessAddressCity
& "||" & "ZipCode :" & " " & objItem.BusinessAddressPostalCode & "||" &
"Manager :" & " " & objItem.ManagerName & "||" & "Business Phone :" & " " &
objItem.Business2TelephoneNumber & "||" & "Fax :" & " " &
objItem.BusinessFaxNumber & "||" & "Email :" & " " & objItem.Email1Address)
End if
'*********Store all data in Hash
set t3Entries(objItem.FullName ) = CreateObject("Scripting.Dictionary")
With t3Entries(objItem.FullName)
.Add "Name",objItem.FullName
.Add "Title",objItem.JobTitle
.Add "Company",objItem.CompanyName
.Add "Department",objItem.Department
.Add "Office",objItem.OfficeLocation
.Add "Phone",objItem.BusinessTelephoneNumber
.Add "Mobile",objItem.MobileTelephoneNumber
.Add "Address",objItem.BusinessAddress
.Add "City",objItem.BusinessAddressCity
.Add "ZipCode",objItem.BusinessAddressPostalCode
.Add "Manager",objItem.ManagerName
.Add "BusinessPhone",objItem.Business2TelephoneNumber
.Add "Fax", objItem.BusinessFaxNumber
.Add "Email",objItem.Email1Address
End with
'MsgBox t3Entries( objItem.FullName)("Name")
WriteLog(t3Entries(objItem.FullName)("Name"))
Next
WriteLog("################## /T3-Directory Data ######################")
wScript.Echo "Log entered in T3-Directory"
Set objOL = Nothing
Set objNS = Nothing
Set objExpl = Nothing
End Sub
'--------------------------------- SQL SERVER PROCEDURES
' Open Sql Server Connection
Sub Sql_OpenConnection
Set Sql_Connection = CreateObject("ADODB.Connection")
'Sql_Connection.Open
"provider=sqloledb;server=t3db1;UID=dbatmm;PWD=dbatmm;database=tmm"
Sql_Connection.Open "provider=sqloledb;server=local;UID=sa;PWD=
;database=tmm"
Sql_Connection.CommandTimeout=100
End Sub
Sub Sql_CloseConnection
Sql_Connection.Close
Set Sql_Connection = Nothing
End Sub
'<------------------------------- Main
------------------------------------------>
Call Init
Call WriteLog("<---------------------- Start " & now & "
------------------->")
'Call Sql_OpenConnection
Call T3dir()
Call cdofun()
'Call Sql_CloseConnection
Call WriteLog("<---------------------- End " & now & " ------------------->")
The problem here is "Saving".Even if we try with Admin Credentials, it is
not Saving.
I tried the same with MAPI.Session instead of Redemption.RDOSession.
It is telling "Activex Component can't create object:'MAPI.Session'".
But I found MAPI32.dll is in Program Files along with Microsoft Outlook.
Could you Please help me how can I Proceed further?
-Vadivu
Redemption,I can retrieve all the data from GAL as well as From my Local
directory.
The intension of this Program is compare the details of GAL with Local
directory, and if any details of GAL vary from Local directory that Local
directory item has to be updated in GAL.
Program:
wScript.Echo "MAPI Test"
Const AppPath = "D:\BODEV\"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const CdoPR_GIVEN_NAME = &H3A06001E
Const CdoPR_ENTRYID = &HFFF0102
Const CdoPR_DISPLAY_NAME =&H3001001E
Const CdoPR_TITLE = &H3A17001E
Const CdoPR_COMPANY_NAME =&H3A16001E
Const CdoPR_DEPARTMENT_NAME =&H3A18001E
Const CdoPR_OFFICE_LOCATION =&H3A19001E
Const CdoPR_BUSINESS_TELEPHONE_NUMBER =&H3A08001E
Const CdoPR_MOBILE_TELEPHONE_NUMBER = &H3A1C001E
Const CdoPR_STREET_ADDRESS =&H3A29001E
Const CdoPR_LOCALITY = &H3A27001E
Const CdoPR_POSTAL_CODE =&H3A2A001E
Const CdoPR_BUSINESS2_TELEPHONE_NUMBER =&H3A1B001E
Const CdoPR_PRIMARY_FAX_NUMBER =&H3A23001E
Const CdoPR_EMAIL=&H39FE001E
Dim filesys
Dim LogFilePath
Dim t3Entries
Dim galEntries
Set t3Entries = CreateObject("Scripting.Dictionary")
Sub Init
Call Init_LogFile()
End Sub
Sub Init_LogFile()
Dim CurDate, LogDate, AppName
dim filetxt, getname, path
AppName = "Test"
CurDate = Date
LogDate = Year(CurDate)
If Len(Month(CurDate)) = 1 Then
LogDate = LogDate & "0" & Month(CurDate)
Else
LogDate = LogDate & Month(CurDate)
End If
If Len(Day(CurDate)) = 1 Then
LogDate = LogDate & "0" & Day(CurDate)
Else
LogDate = LogDate & Day(CurDate)
End If
LogFilePath = AppPath & "Log\" & AppName & "_" & LogDate & ".log"
End Sub
Sub WriteLog(toWrite)
Dim LogFile
Dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
Set LogFile = filesys.OpenTextFile(LogFilePath,ForAppending,True)
LogFile.WriteLine toWrite
LogFile.close
Set LogFile = Nothing
End Sub
Sub cdofun()
Dim t3Item, isModified, t3EntryName
Set session = CreateObject("Redemption.RDOSession")
Dim t3DetailsByName
Set t3DetailsByName = CreateObject ("Scripting.Dictionary")
Session.Logon
MsgBox(session.currentuser & " " &"Logged In")
set AddrList = Session.AddressBook.AddressLists.Item("Global Address
List")
MsgBox "There are " & AddrList.AddressEntries.Count & " items in the
GAL"
Set objAddressEntries = AddrList.AddressEntries
int i=0
MsgBox(t3entries.count)
WriteLog("############## Compare GAL with T3-Dir #################")
For Each t3Item In t3entries.Keys
on error resume next
t3EntryName = t3Item
t3DetailsByName = t3entries(t3Item)
objAddressEntry = objAddressEntries.Item(t3EntryName)
Set isModified = 0
Set objAddressFields = objAddressEntry.Fields
MsgBox "From T3 " & t3EntryName
If Not objAddressFields is Nothing Then
WriteLog ("GAL Entries Before Comparision ")
MsgBox("Before Comparision")
MsgBox("Object Entry name " & objAddressEntry.Name)
WriteLog ("Name : " & " " & objAddressEntry.Name & "||" & " " &
"Manager :" & " " & objAddressEntry.Manager &"||" & " "&"JobTitle :" & " " &
objAddressEntry.Fields(CdoPR_TITLE) &"||" &" " & "Company :" & " " &
objAddressEntry.Fields(CdoPR_COMPANY_NAME) &"||" & " " &"Department :" & " "
& objAddressEntry.Fields(CdoPR_DEPARTMENT_NAME) &"||" & " " & "Office :" & "
" & objAddressEntry.Fields(CdoPR_OFFICE_LOCATION) &"||" & " "&"Phone :" & " "
& objAddressEntry.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER) &"||" & " "
&"Mobile :" & " " & objAddressEntry.Fields(CdoPR_MOBILE_TELEPHONE_NUMBER)
&"||" & " " & "Address :" & " " &
objAddressEntry.Fields(CdoPR_STREET_ADDRESS) &"||" & " "&"City :" & " " &
objAddressEntry.Fields(CdoPR_LOCALITY) &"||" & " "&"ZipCode :" & " " &
objAddressEntry.Fields(CdoPR_POSTAL_CODE) &"||" & " " &"Business Phone :" & "
" & objAddressEntry.Fields(CdoPR_BUSINESS2_TELEPHONE_NUMBER) &"||" & " "&"Fax
:" & " " & objAddressEntry.Fields(CdoPR_PRIMARY_FAX_NUMBER) &"||" & " "
&"E-Mail :" & " " & objAddressEntry.Fields(CdoPR_EMAIL))
End If
'Get the corresponding entry from t3 directory
t3DetailsByName = t3Entries(objAddressEntry.Name)
MsgBox "From GAL " & objAddressEntry.Fields (CdoPR_TITLE)
MsgBox "From T3 " & t3DetailsByName("Title")
If objAddressEntry.Fields (CdoPR_TITLE) <>
t3DetailsByName("Title") Then
isModified = 1
objAddressEntry.Fields(CdoPR_TITLE) = t3DetailsByName("Title")
ElseIf objAddressEntry.Fields (CdoPR_COMPANY_NAME) <>
t3DetailsByName("Company") Then
objAddressEntry.Fields (CdoPR_COMPANY_NAME) =
t3DetailsByName("Company")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_DEPARTMENT_NAME) <>
t3DetailsByName("Department")Then
objAddressEntry.Fields (CdoPR_DEPARTMENT_NAME) =
t3DetailsByName("Department")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) <>
t3DetailsByName("Office")Then
objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) =
t3DetailsByName("Office")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) <>
t3DetailsByName("Office")Then
objAddressEntry.Fields (CdoPR_OFFICE_LOCATION) =
t3DetailsByName("Office")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_BUSINESS_TELEPHONE_NUMBER)
<> t3DetailsByName("Phone")Then
objAddressEntry.Fields (CdoPR_BUSINESS_TELEPHONE_NUMBER) =
t3DetailsByName("Phone")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_MOBILE_TELEPHONE_NUMBER) <>
t3DetailsByName("Mobile")Then
objAddressEntry.Fields (CdoPR_MOBILE_TELEPHONE_NUMBER) =
t3DetailsByName("Mobile")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_STREET_ADDRESS) <>
t3DetailsByName("Address")Then
objAddressEntry.Fields (CdoPR_STREET_ADDRESS) =
t3DetailsByName("Address")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_LOCALITY) <>
t3DetailsByName("City")Then
objAddressEntry.Fields (CdoPR_LOCALITY) = t3DetailsByName("City")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_POSTAL_CODE) <>
t3DetailsByName("ZipCode")Then
objAddressEntry.Fields (CdoPR_POSTAL_CODE) = t3DetailsByName("ZipCode")
isModified = 1
ElseIf objAddressEntry.Manager <> t3DetailsByName("Manager")Then
objAddressEntry.Manager = t3DetailsByName("Manager")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_BUSINESS2_TELEPHONE_NUMBER)
<> t3DetailsByName("BusinessPhone")Then
objAddressEntry.Fields (CdoPR_BUSINESS2_TELEPHONE_NUMBER) =
t3DetailsByName("BusinessPhone")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_PRIMARY_FAX_NUMBER) <>
t3DetailsByName("Fax")Then
objAddressEntry.Fields (CdoPR_PRIMARY_FAX_NUMBER) =
t3DetailsByName("Fax")
isModified = 1
ElseIf objAddressEntry.Fields (CdoPR_EMAIL) <>
t3DetailsByName("Email")Then
objAddressEntry.Fields (CdoPR_EMAIL) = t3DetailsByName("Email")
isModified = 1
End If
If isModified=1 Then
WriteLog ("GAL Entries after update")
MsgBox( objAddressEntry.Name)
WriteLog ("Name : " & " " & objAddressEntry.Name & "||" & " " &
"Manager :" & " " & objAddressEntry.Manager &"||" & " "&"JobTitle :" & " " &
objAddressEntry.Fields(CdoPR_TITLE) &"||" &" " & "Company :" & " " &
objAddressEntry.Fields(CdoPR_COMPANY_NAME) &"||" & " " &"Department :" & " "
& objAddressEntry.Fields(CdoPR_DEPARTMENT_NAME) &"||" & " " & "Office :" & "
" & objAddressEntry.Fields(CdoPR_OFFICE_LOCATION) &"||" & " "&"Phone :" & " "
& objAddressEntry.Fields(CdoPR_BUSINESS_TELEPHONE_NUMBER) &"||" & " "
&"Mobile :" & " " & objAddressEntry.Fields(CdoPR_MOBILE_TELEPHONE_NUMBER)
&"||" & " " & "Address :" & " " &
objAddressEntry.Fields(CdoPR_STREET_ADDRESS) &"||" & " "&"City :" & " " &
objAddressEntry.Fields(CdoPR_LOCALITY) &"||" & " "&"ZipCode :" & " " &
objAddressEntry.Fields(CdoPR_POSTAL_CODE) &"||" & " " &"Business Phone :" & "
" & objAddressEntry.Fields(CdoPR_BUSINESS2_TELEPHONE_NUMBER) &"||" & " "&"Fax
:" & " " & objAddressEntry.Fields(CdoPR_PRIMARY_FAX_NUMBER) &"||" & " "
&"E-Mail :" & " " & objAddressEntry.Fields(CdoPR_EMAIL))
'Save the entry again to GAL with the updates
'Currently Saving the entry is not working because of access right
issues
'Uncomment the following line once that is fixed
'objAddressEntry.Save
Else
WriteLog ("GAL details for this employee matches with T3 details")
End If
Next
MsgBox("Comparison Over")
End Sub
Sub T3dir()
Dim objOL
Dim objNS 'Outlook namespace
Dim objExpl
Dim colCB
Dim objFindCBB
Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
MsgBox "From T3-Directory"
'display contacts as active folder
Set objExpl = objOL.ActiveExplorer
Set objPFldr = objNS.Folders.Item ("Public Folders")
Set objAPF = objPFldr.Folders.Item("All Public Folders")
'MsgBox objAPF.Name
Set objT3Dir = objAPF.Folders.Item("T3-Directory")
MsgBox objT3Dir.Name
MsgBox " There are " & objT3Dir.Items.Count & " " &"items in T3-Directory"
MsgBox objT3Dir.Display
set objItem =objT3Dir.Items
WriteLog(" ")
WriteLog("##################### T3-Directory Data ######################")
For each objItem in objT3Dir.Items
If Not objItem is Nothing Then
WriteLog ("Name :" & " " & objItem.FullName & "||" & "Job_Title :" & " "
& objItem.JobTitle & "||" & "Company :" & " " & objItem.CompanyName & "||" &
"Department :" & " " & objItem.Department & "||" & "Office :" & " " &
objItem.OfficeLocation & "||" & "Phone :" & " " &
objItem.BusinessTelephoneNumber & "||" & "Mobile :" & " " &
objItem.MobileTelephoneNumber & "||" & "Address :" & " " &
objItem.BusinessAddress & "||" & "City :" & " " & objItem.BusinessAddressCity
& "||" & "ZipCode :" & " " & objItem.BusinessAddressPostalCode & "||" &
"Manager :" & " " & objItem.ManagerName & "||" & "Business Phone :" & " " &
objItem.Business2TelephoneNumber & "||" & "Fax :" & " " &
objItem.BusinessFaxNumber & "||" & "Email :" & " " & objItem.Email1Address)
End if
'*********Store all data in Hash
set t3Entries(objItem.FullName ) = CreateObject("Scripting.Dictionary")
With t3Entries(objItem.FullName)
.Add "Name",objItem.FullName
.Add "Title",objItem.JobTitle
.Add "Company",objItem.CompanyName
.Add "Department",objItem.Department
.Add "Office",objItem.OfficeLocation
.Add "Phone",objItem.BusinessTelephoneNumber
.Add "Mobile",objItem.MobileTelephoneNumber
.Add "Address",objItem.BusinessAddress
.Add "City",objItem.BusinessAddressCity
.Add "ZipCode",objItem.BusinessAddressPostalCode
.Add "Manager",objItem.ManagerName
.Add "BusinessPhone",objItem.Business2TelephoneNumber
.Add "Fax", objItem.BusinessFaxNumber
.Add "Email",objItem.Email1Address
End with
'MsgBox t3Entries( objItem.FullName)("Name")
WriteLog(t3Entries(objItem.FullName)("Name"))
Next
WriteLog("################## /T3-Directory Data ######################")
wScript.Echo "Log entered in T3-Directory"
Set objOL = Nothing
Set objNS = Nothing
Set objExpl = Nothing
End Sub
'--------------------------------- SQL SERVER PROCEDURES
' Open Sql Server Connection
Sub Sql_OpenConnection
Set Sql_Connection = CreateObject("ADODB.Connection")
'Sql_Connection.Open
"provider=sqloledb;server=t3db1;UID=dbatmm;PWD=dbatmm;database=tmm"
Sql_Connection.Open "provider=sqloledb;server=local;UID=sa;PWD=
;database=tmm"
Sql_Connection.CommandTimeout=100
End Sub
Sub Sql_CloseConnection
Sql_Connection.Close
Set Sql_Connection = Nothing
End Sub
'<------------------------------- Main
------------------------------------------>
Call Init
Call WriteLog("<---------------------- Start " & now & "
------------------->")
'Call Sql_OpenConnection
Call T3dir()
Call cdofun()
'Call Sql_CloseConnection
Call WriteLog("<---------------------- End " & now & " ------------------->")
The problem here is "Saving".Even if we try with Admin Credentials, it is
not Saving.
I tried the same with MAPI.Session instead of Redemption.RDOSession.
It is telling "Activex Component can't create object:'MAPI.Session'".
But I found MAPI32.dll is in Program Files along with Microsoft Outlook.
Could you Please help me how can I Proceed further?
-Vadivu