• Products
    • View all products
    • Free trials
  • Solutions
    • All Solutions
    • All Integrations
  • Resources
    • All Resources
    • Learning Hub
  • Trials
  • Support
    • Support Home
    • By Product
      • All Products
      • Active Roles
      • Authentication Services
      • Cloud Access Manager
      • Defender
      • Identity Manager
      • Password Manager
      • Safeguard
      • Starling Identity Analytics & Risk Intelligence
      • Starling Two-Factor Authentication
      • TPAM Appliance
    • Contact Support
      • Overview
      • Customer Service
      • Licensing Assistance
      • Renewal Assistance
      • Technical Support
    • Download Software
    • Knowledge Base
    • My Account
      • My Products
      • My Service Requests
      • My Licenses
      • My Groups
      • My Profile
    • Policies & Procedures
    • Professional Services
    • Technical Documentation
    • One Identity University
    • User Forums
    • Video Tutorials
  • Partners
    • Overview
    • Partner Circle Log In
    • Become a Partner
    • Find a Partner
    • Partner Community
  • Communities
    • Home
    • Blogs
      • Blogs A to Z
      • One Identity Community
      • AD Account Lifecycle Management
      • Cloud
      • Identity Governance & Administration
      • Privileged Access Management
      • syslog-ng Community
    • Forums
      • All Product Forums
      • Active Roles
      • Identity Manager
      • Password Manager
      • Safeguard
      • Unix Access Management
    • Social Networks
      • Facebook
      • LinkedIn
      • Twitter
      • YouTube
One Identity Community
One Identity Community
  • Site
  • User
  • Site
  • Search
  • User
Active Roles Community
Active Roles Community
Wiki Change default SMTP address
  • Forum
  • Ideas
  • Wiki
  • More
  • Cancel
  • New
  • -Active Roles Script Center
    • +Active Roles Script Policy Best Practices
    • Active Roles SDK
    • +C#
    • +JavaScript
    • +PowerShell
    • -VBScript
      • VBScript Library source code
      • -VBScript samples
        • A Managed Unit with users which have not logged on for last 90 days
        • Adjust the case of usernames to title case (first letter of each part of the name)
        • Advanced group creation/provision
        • Advanced shared folder creation
        • Bulk policy incompliance fixing
        • Check unique value of an attribute
        • +Computer management
        • -Exchange management
          • Change default SMTP address
          • Custom script-based mailbox store selection policy
          • Execute an Exchange cmdlet in script policy
          • Force Mailbox-Creation Policy upon User creation outside of Active Roles
          • How to prevent a mailbox creation on the New User Wizard
          • How to remove X400 address
          • Select Exchange mailbox store on user copy
        • Function that converts regular date into integer8 format
        • Get effective policy info list
        • +Group management
        • How to find a request source in script policy
        • How to send emails based on scripts policy parameters and Virtual Attribute values
        • +Permissions Management
        • Policy incompliance reporting & fixing for specified policy
        • Populate values from a SQL database to an AD Attribute
        • Prevent copying an attribute on user copy
        • Prohibite a permission propagation to AD
        • Prohibite an AD native security editing
        • Read large integer date attributes and display them in date and time readable format
        • Read XML Node text or attribute value
        • Read XML Node with Children into DictionaryObject
        • Standalone script that requests built-in password generation policy
        • +User management
        • Validate moving operations
        • +VBScript: Approval

You are currently reviewing an older revision of this page.

  • History View current version

Change default SMTP address

Back to Exchange management

DESCRIPTION

This function will change the default SMTP address for a given user and new SMTP address.


Note This code may use functions from the ARS Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.


SCRIPT

'*********************************************************************************

' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

' WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

'

' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

' PLEASE CONTACT QUEST PROFESSIONAL SERVICES.

'*********************************************************************************

'

' This code is published on the ActiveRoles Script Center:

' http://communities.quest.com/docs/DOC-9991

'

' This code may use functions from the ARS Script Policy Best Practices:

' http://communities.quest.com/docs/DOC-10016

'

' Please, follow the link to obtain instructions and code for those functions.

'*********************************************************************************

'Add Script Here

'you will need to pass it object that is the user, and the SMTP address that you will want to use.

'we use this inside an on "post modify" where it is looking to see if the first or last name was changed during the Quick Connect run.

Function changedefaultsmtp (objuser,newsmtp)

objuser.getinfo

newmail = ("SMTP:" & newsmtp) 'setting the email address that will be Default

For Each email In objuser.proxyAddresses 'looping through the proxies looking for anything we need to change before we set the Default

email2 = Left(email,5)

email3 = Ucase(email2) 'did this becuase ARS was having problems doing all this in one line.

If email3 = "SMTP:" Then

useremail = Mid(email, 6) 'this is the e-mail we are checking against

If ucase(useremail) = ucase(newsmtp) Then 'checking to make sure that the "newmail" doesn't already exist

objUser.PutEx ADS_PROPERTY_DELETE, "proxyAddresses", Array(email) 'delete that entry

objUser.SetInfo

Exit For 'dump out of the FOR next, we found that the user had this address already, and removed it, we will set it as default.

Else

If email2 = "SMTP:" Then 'if we find a default address then replace it with a regular address

objUser.PutEx ADS_PROPERTY_DELETE, "proxyAddresses", Array(email)

objUser.SetInfo

objuser.Getinfo

objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", Array(lcase(email))

objUser.SetInfo

End If

End If

End If

Next

'setting new address as Default

objuser.Getinfo

objUser.put "mail",newsmtp

objUser.PutEx ADS_PROPERTY_APPEND, "proxyAddresses", Array(newmail)

On Error Resume Next 'doing this so that we can see if there is an error so we can trap it and return it from the fuction.

objUser.SetInfo

If Err.Number <> 0 Then

changedefaultsmtp = Err.Description

Err.Clear

Else

changedefaultsmtp = "SUCCESS"

End If

'On Error GoTo 0 'probably should be removed since other parts of the script may rely on it.

End Function

'***** END OF CODE ***************************************************************

COMPATIBILITY

Script compatible with the following version(s): <Not specified>

Back to Exchange management

  • Company
    • About Us
    • Buy
    • Careers
    • Contact Us
    • News
  • Resources
    • Blogs
    • Customer Stories
    • Documents
    • Events
    • Videos
  • Support
    • Professional Services
    • Renew Support
    • Technical Support
    • One Identity University
    • Support Service
  • Social Networks
    • Facebook
    • Instagram
    • LinkedIn
    • Twitter
    • YouTube
  • © 2025 One Identity LLC. ALL RIGHTS RESERVED.
  • Legal
  • Terms of Use
  • Privacy
  • Community Feedback & Support
  • Cookie Preference Center