Folgendes Logon-Scrip modifiziert den Postfachnamen und ändert ihn in die Mailadresse des Benutzers.
…in Zeile 13 muss dazu lediglich der zu ersetzende Name angegeben werden.
Dim colStores 'As Outlook.Stores Dim oStore 'As Outlook.Store Dim oRoot 'As Outlook.folder Dim oldName 'As String Dim newName 'As String Set objNetwork = CreateObject("Wscript.Network") strUser = objNetwork.UserName strDomain = objNetwork.UserDomain mailAdr = GetEmail(strUser, strDomain) rem wscript.echo mailAdr oldName = "OldName" newName = mailAdr wscript.echo newName 'On Error Resume Next Set objOutlook = CreateObject("Outlook.Application") Set colStores = objOutlook.Session.Stores For Each oStore In colStores Set oRoot = oStore.GetRootFolder If LCase(oRoot) = LCase(oldName) Then 'wscript.echo oRoot.Name oRoot.Name = newName End If Next Function GetEmail(strAccountName, strDomainName) Dim adoLDAPCon, adoLDAPRS, strLDAP Set adoLDAPCon = CreateObject("ADODB.Connection") adoLDAPCon.Provider = "ADsDSOObject" adoLDAPCon.Open "ADSI" strLDAP = "'LDAP://" & strDomainName & "'" Set adoLDAPRS = adoLDAPCon.Execute("select mail from " & strLDAP & " WHERE objectClass = 'user'" & " And samAccountName = '" & strAccountName & "'") With adoLDAPRS If Not .EOF Then GetEmail = .Fields("mail") Else GetEmail = "" End If End With adoLDAPRS.Close Set adoLDAPRS = Nothing Set adoLDAPCon = Nothing End Function
Postfachnamen in Outlook ändern