Results 1 to 2 of 2

Thread: Maybe a VBScript to pull email addresses?

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Maybe a VBScript to pull email addresses?

    Hi All,

    I have a form/app that users login to for trouble tickets. Below is the what the form/app uses to validate them.
    Code:
    Private Function ValidateLogin( _
    
        ByVal Username As String, _
    
        ByVal Password As String, _
    
        ByVal Domain As String) As Boolean
    
     
    
            Dim token As IntPtr
    
     
    
            ' Call the API
    
            If LogonUser(Username, _
    
            Domain, _
    
            Password, _
    
            LOGON32_LOGON_NETWORK, _
    
            LOGON32_PROVIDER_DEFAULT, token) = True Then
    
     
    
                ' Since the API returned TRUE, return TRUE to the caller
    
                Return True
    
            Else
    
                ' Bad credentials, return FALSE
    
                Return False
    
            End If
    
        End Function
    What I would like to do now is have it search AD for their email address and populate the fields in my form.
    Code:
    Populate Last, First (Manager_Text.text)
    
    Populate email (director.text)
    Any help out there??

  2. #2
    Join Date
    Jun 2006
    Posts
    623

    Re: Maybe a VBScript to pull email addresses?

    Check the below script Hi that uses a regular expression to attempt to extract all legal email addresses from a string as an example:

    Code:
     Dim strPattern, arrAllMatches, strMatch, strMatches 
     
    strPattern = "([\w-\.]+)@\w{2,}(\.\w{2,}){1,5}(;([\w-\.]+)@\w{2,}(\.\w{2,}){1,5})*?" 
     
    strTestString = " envonfv ofnvfv fkdjfnv;djfn;dn email@domain.com.sdvzsd vj>ยจ^c zcln test@domain.com" & vbCrlf _ 
                  & " vsifdvjzs0v8djzs0fivdj zsofvn>anothermail@domain.com >| xidisdvnsv " 
     
    colAllMatches = fGetMatches(strPattern, strTestString) 
     
    For Each strMatch In colAllMatches 
        strMatches = strMatches & strMatch & vbCrlf 
    Next 
     
    MsgBox strMatches,, "Email Addresses found:" 
     
    Function fGetMatches(sPattern, sStr) 
        Dim regEx, retVal, sMatch, colMatches, temp 
        Set regEx = New RegExp     ' Create a regular expression. 
        regEx.Pattern = sPattern   ' Set pattern. 
        regEx.IgnoreCase = True   ' Set case insensitivity. 
        regEx.Global = True        ' Set global applicability. 
     
        Set colMatches = regEx.Execute(sStr)   ' Execute search. 
        '# Convert Collection to Array 
        For Each sMatch In colMatches 
            temp = temp & sMatch & vbCrlf 
        Next 
        temp = Split(temp, vbCrlf) 
        fGetMatches = temp 
     
    End Function

Similar Threads

  1. Replies: 1
    Last Post: 08-06-2012, 06:41 PM
  2. how to trace email addresses?
    By geokilla in forum Windows Software
    Replies: 5
    Last Post: 07-08-2009, 07:54 PM
  3. Replies: 2
    Last Post: 30-07-2009, 05:14 PM
  4. how to pull local group members in vbscript?
    By vivekmohan in forum Software Development
    Replies: 3
    Last Post: 25-07-2009, 01:52 PM
  5. how to pull NTFS security permission in vbscript
    By vivekmohan in forum Software Development
    Replies: 3
    Last Post: 25-07-2009, 01:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,460,716.32240 seconds with 17 queries