Checks whether the specified email account exists in Microsoft Outlook. Requires Microsoft Office 2007 or newer. Returns true if the email account exists and false if it doesn’t.

Function

VBA
Function EmailAccountExists(strAccount As String) As Boolean Dim olApp As Object, olNS As Object Dim varItem As Variant Set olApp = CreateObject("Outlook.Application") Set olNS = olApp.GetNamespace("MAPI") For Each varItem In olApp.Session.Accounts If varItem.SmtpAddress = strAccount Then EmailAccountExists = True Exit Function End If Next varItem End Function

Parameters

NameOptional/
Required
Data typeDescription
strAccountRequiredStringThe name of the email account to be checked.

Usage example

VBA
Sub TestEmailAccountExists() Debug.Print EmailAccountExists("test@test.com") ' true = email account exists, false = email acccount does not exist End Sub