![]() ![]() ' sInput : String to parse/extract e-mail addresses from ' Req'd Refs: Uses Late Binding, so none required ' Copyright : The following is release as Attribution-ShareAlike 4.0 International ' Purpose : Extract e-mail addresses from a supplied string ' Author : Daniel Pineault, CARDA Consultants Inc. , vbOKOnly + vbCritical, "An Error has Occured!" Resume Error_Handler_Exit Switch(Erl = 0, "", Erl 0, vbCrLf & "Line No: " & Erl) _ "Error Description: " & Err.Description & _ ![]() "Error Source: ExtractEmailAddresses" & vbCrLf & _ "Error Number: " & Err.Number & vbCrLf & _ MsgBox "The following error has occured" & vbCrLf & vbCrLf & _ On Error Resume Next If Not oMatch Is Nothing Then Set oMatch = Nothing If Not oMatches Is Nothing Then Set oMatches = Nothing If Not oRegEx Is Nothing Then Set oRegEx = Nothing Exit Function If Right(sEmail, 1) = "," Then sEmail = Left(sEmail, Len(sEmail) - 1)Ä®xtractEmailAddresses = Split(sEmail, ",") 'Return an array of email addresses extracted from sInput Else 'Basic pattern '.Pattern = 'More advanced pattern that allow accented characters ' Website : ' Purpose : Extract e-mail addresses from a supplied string ' Notes : None ' Copyright : The following is release as Attribution-ShareAlike 4.0 International ' (CC BY-SA 4.0) - ' Req'd Refs: Uses Late Binding, so none required ' ' Input Variables: ' ~~~~~~~~~~~~~~~~ ' sInput : String to parse/extract e-mail addresses from ' ' Usage: ' ~~~~~~ ' See TestMe Sub ' ' Revision History: ' Rev Date(yyyy/mm/dd) Description ' ************************************************************************************** ' 1 Initial Release, Forum Help ' 2 Added a more advanced pattern '- Public Function ExtractEmailAddresses( ByVal sInput As Variant) As Variant On Error GoTo Error_HandlerÄim oRegEx As Object Dim oMatches As Object Dim oMatch As Object Dim sEmail As String If Not IsNull(sInput) Then Set oRegEx = CreateObject( "vbscript.regexp") '- ' Procedure : ExtractEmailAddresses ' Author : Daniel Pineault, CARDA Consultants Inc. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |