79709916

Date: 2025-07-22 05:22:16
Score: 0.5
Natty:
Report link

For a basic check use the split function. This function is for checking excel cells so you may not have to use Variant (Also with thanks to @Erik A)

Public Function IsokEmailAddresses(InString As Variant) As Boolean
Dim EmailArray() As String
Dim TmpString As String
Dim TheStr As String
Dim i As Long

' Blank email is ok??
'[email protected]<SomeName;[email protected] Valid, 2 addresses, first one named SomeName
'a@ a < a.com Invalid, < needs to be escaped
'[email protected];;[email protected]; Valid, 2 addresses
'[email protected];a Invalid, second address is not valid
'a<[email protected] 'Weirdly enough, this is valid according to outlook, mails to [email protected]
          '(ignores part before the <)
'[email protected]<[email protected] 'But this isn't valid
                '(closing > needed in this specific case, mail address = [email protected])
                
'vacant? - I think this is ok - its valid as I think we still snail mail some objections
'IsVacant is space, blank or a single ' character
If isempty(InString) Then
  IsokEmailAddresses = True
  Exit Function
'if it's just a number it's not an email address
ElseIf IsNumeric(InString) Then
  IsokEmailAddresses = False
  Exit Function
End If

TmpString = Str(InString)
  
                
EmailArray = Split(TmpString, ";")

For i = 1 To UBound(EmailArray)
  TheStr = Trim(EmailArray(i)) 'trim either end
  'Look for spaces in the middle
  If InStr(1, TheStr, " ", vbTextCompare) > 0 Then
    IsokEmailAddresses = False
    Exit Function
  End If
  If Not (InStr(1, TheStr, "@", vbTextCompare) > 0) Then
    IsokEmailAddresses = False
    Exit Function
Next i

IsokEmailAddresses = True


End Function
Reasons:
  • Blacklisted phrase (0.5): thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Erik
  • Low reputation (0.5):
Posted by: LeasMaps