This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get Email from User Account (vbscript)

Former Member
Former Member
Hello guys,


Is it possible to get the email from a User Account in VBScript?. If yes may I see your sample code?, And in addition, I want to ask you on how to foreach in the multiple user account in vbscript. Thank you in Advance :)


Best Regards, Sean
  • Former Member
    Former Member
    Assuming that your UserAccount object is call oUA:

    'get the log in account from the user account name
    Dim oLA : Set oLA = Vault.LoginAccountOperations.GetLoginAccount(oUA.LoginName)
    'get the email address from the log in account
    Dim sEM : sEM = oLA.EmailAddress

  • Former Member
    Former Member
    Thanks, Sir James Carter



    Best Regards Sean
  • Former Member
    Former Member
    Hello sir,

    What if I have employee object and document object and I want to get the email of the employee that is assigned to document how will I do that?

    BR,
  • Former Member
    Former Member
    Hi Sean,
    that depends on what you mean by "the employee is assigned to the document"

    Do you mean that there is a property on the document meta data card that is a single select list of object: Employee
    And each Employee object in turn has a single select dropdown list property of "m-files user"
  • I did a try wih this code but I'm getting an error message about to create a registry key to enable especific vault login accounts required for this procedure because the option is not available any more...


    Dim oUA : oUA = PropertyValues.SearchForProperty(1038).TypedValue.DisplayValue
    'get the log in account from the user account name
    Dim oLA : Set oLA = Vault.LoginAccountOperations.GetLoginAccount(oUA).LoginName
    'get the email address from the log in account
    Dim sEM : sEM = oLA.EmailAddress
    Output = sEM


  • Try the following (if oUA is your user account object):

    Vault.UserOperations.GetLoginAccountOfUser(oUA.ID).EmailAddress
  • Former Member
    Former Member
    Hi Jfredes,
    is your problem because you have mistake in your code snippet?

    Dim oLA : Set oLA = Vault.LoginAccountOperations.GetLoginAccount(oUA).LoginName
    should be:
    Dim oLA : Set oLA = Vault.LoginAccountOperations.GetLoginAccount(oUA.LoginName)
  • Former Member
    Former Member
    I got an error saying "Object required: Will Smith"

    These are the code i tried :

    1).
    Option Explicit
    Dim oUA : oUA = PropertyValues.SearchForProperty(1021).TypedValue.DisplayValue ' value of the User Account pv
    'get the log in account from the user account name
    'Dim oLA : Set oLA = Vault.LoginAccountOperations.GetLoginAccount(oUA.LoginName)
    'get the email address from the log in account
    'Dim sEM : sEM = oLA.EmailAddress
    'Output = sEM

    2).
    Option Explicit
    Dim oUA : oUA = PropertyValues.SearchForProperty(1021).TypedValue.DisplayValue ' value of the User Account pv
    'get the log in account from the user account name
    Dim sEM : sEM = Vault.UserOperations.GetLoginAccountOfUser(oUA.ID).EmailAddress
    Output = sEM

    Both had the same error,

    Br,
  • Former Member
    Former Member
    this line of code is your problem:

    Dim oUA : oUA = PropertyValues.SearchForProperty(1021).TypedValue.DisplayValue ' value of the User Account pv

    you are assuming that you are getting the a user account object here, when in fact you are getting the display value (string) - the user account name

    if your property 1021 is a single select look up of user accounts then try this

    'get the user account id
    Dim iUserAccountId : iUserAccountId = PropertyValues.SearchForProperty(1021).TypedValue.GetLoookupID()
    'get the log in account from the user account ID and get the email address from the login account
    Dim sEM : sEM = Vault.UserOperations.GetLoginAccountOfUser(iUserAccountId).EmailAddress
    Output = sEM
  • Former Member
    Former Member
    Hello Sir,

    It shows an error "Object doesn't support this property or method: GetLookupID()".
    I attached the user account pv's pic

    Br,