Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Script to export Exchange users default SMTP email address

lengoo (IS/IT--Management) (OP)
26 Feb 03 5:13
Hi All,
Does anyone have a script that could read into AD and export each user default SMTP email address with their full names to an Excel CSV or tab delimited file?
Thanks
mrmovie (TechnicalUser)
26 Feb 03 5:42
below gets it from exchange, we dont populate ad with the upto date information.

ad query would be

'########
strUser = InputBox("Enter your name")

Set user = GetObject("WinNT://domfsc01/" & strUser & ",user")

msgbox user.Profile

'#####

but i am not sure what the property for the mail address is


'#######


Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oCommand = CreateObject("ADODB.Command")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open = "Active Directory Provider"
oCommand.ActiveConnection = oConnection
oCommand.Properties("Page Size") = 100
oCommand.Properties("Timeout") = 30
oCommand.Properties("Searchscope") = 2
oCommand.Properties("Cache Results") = False

Set oRS = oConnection.Execute("SELECT mail,uid,sn,givenName FROM 'LDAP://abg0970e.abg.fsc.net' WHERE uid='" & WshNetwork.Username & "'")

'While Not oRS.EOF
If oRS.RecordCount = 1 Then                    For i = 0 To oRS.Fields.Count - 1    
        If IsArray(oRS.Fields(i).value) Then
            aArray = oRS.Fields(i).Value
            
            If oRS.Fields(i).Name = "sn" Then
                strSN = aArray(0)
            ElseIf oRS.Fields(i).Name = "givenName" Then
                strGN = aArray(0)
            End If
            'msgbox oRS.Fields(i).Name & ": " & aArray(0)
            WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\" & oRS.Fields(i).Name, aArray(0)
        Else
            If oRS.Fields(i).Name = "sn" Then
                strSN = oRS.Fields(i)
            ElseIf oRS.Fields(i).Name = "givenName" Then
                strGN = oRS.Fields(i)
            End If


            'msgbox oRS.Fields(i).Name & ": " & oRS.Fields(i)
            WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\" & oRS.Fields(i).Name, oRS.Fields(i).Value
        End If
    Next
    'oRS.MoveNext
    WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\commonNameNational", strGN & " " & strSN
Else
    
    WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\sn", strUserName
    WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\mail", strUserName & "@fujitsu-siemens.com"
    WshShell.RegWrite "HKCU\Software\WASP\NetWorker Laptop_6.2_EN\commonNameNational", strUserName

End If
'Wend
  
Set oRS = Nothing
Set oConnection = Nothing
Set oCommand = Nothing
Set WshNetwork = Nothing
Set WshShell = Nothing  
  

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close