.Net
Official ZeroBounce .NET API v2 Wrapper :
You can also easily consume and keep it updated within your Visual Studio Project with Nuget Package Manager:
This wrapper class takes all the work out of coding against the API and allows you to easily set properties and get results instantly.The .NET API Wrapper takes these input parameters.
The ValidateEmail and GetCredit methods return objects from which you can easily retrieve properties the properties below.
Properties and possible values returned by the methods:
NET API Parameters
- PropertyPossible Values
- api_keyThe API key found in your account dashboard
- emailToValidateThe email address you are validating
- ip_address[optional] - The IP Address the email was captured from
- requestTimeOutTimeout settings in milliseconds, setting this enables you to control how long you are willing to wait for to send the request to the API. When the timeout occurs an "Unknown" result is returned
- readTimeOutTimeout settings in milliseconds, setting this enables you to control how long you are willing to wait for the API to respond to your request. When the timeout occurs an "Unknown" result is returned
The ValidateEmail and GetCredit methods return objects from which you can easily retrieve properties the properties below.
Properties and possible values returned by the methods:
validate method
- PropertyPossible Values
- addressThe email address you are validating.
- statusvalidinvalidcatch-allunknownspamtrapabusedo_not_mail
- sub_statusantispam_systemgreylistedmail_server_temporary_errorforcible_disconnectmail_server_did_not_respondtimeout_exceededfailed_smtp_connectionmailbox_quota_exceededexception_occurredpossible_trapsrole_basedglobal_suppressionmailbox_not_foundno_dns_entriesfailed_syntax_checkpossible_typounroutable_ip_addressleading_period_removeddoes_not_accept_mailalias_addresstoxicdisposablerole_based_catch_all
- accountThe portion of the email address before the "@" symbol.
- domainThe portion of the email address after the "@" symbol.
- did_you_meanSuggestive fix for an email typo or [null]
- domain_age_daysAge of the email domain in days or [null]
- free_email[true/false] If the email comes from a free provider
- mx_found[true/false] Does the domain have an MX record
- mx_recordThe preferred MX record of the domain or [null]
- smtp_providerThe SMTP Provider of the email or [null] (BETA)
- lastnameThe last name of the owner of the email when available or [null]
- genderThe gender of the owner of the email when available or [null]
- countryThe country the IP address is from
- regionThe state/region the IP address is from
- cityThe city the IP address is from
- zipcodeThe Zip Code the IP address is from
- processed_atThe UTC time the email was validated
GetCredit method
- PropertyPossible Values
- creditsThe number of credits left in account for email validation.
C#
var zeroBounceAPI = new ZeroBounce.ZeroBounceAPI();
//set input parameters
zeroBounceAPI.api_key = "Your API Key"; //Required
zeroBounceAPI.emailToValidate = "Email address you are validating"; //Required
zeroBounceAPI.ip_address = "IP address the email signed up with"; //Optional
//Depending on how you use the API, you might want it to time out faster, for example on a registration screen.
//Normally the API will return results very fast, but a small percentage of mail servers take
//upwards of 20+ seconds to respond.
//If the API times out, it will return a status of "Unknown" and a sub_status of "timeout_exceeded"
zeroBounceAPI.readTimeOut = 200000;// "Any integer value in milliseconds
zeroBounceAPI.requestTimeOut = 150000; // "Any integer value in milliseconds
//validate email and assign results to an object
var apiProperties = zeroBounceAPI.ValidateEmail();
//check credits and assign results to an object
var apiCredits= zeroBounceAPI.GetCredits();
//use the properties to make decisions on
switch (apiProperties.status)
{
case "invalid":
Console.WriteLine("invalid");
break;
case "valid":
Console.WriteLine("valid");
break;
default:
Console.WriteLine(apiProperties.status);
break;
}
VB .NET
Dim zeroBounceAPI = New ZeroBounce.ZeroBounceAPI
'set input parameters
zeroBounceAPI.api_key = "Your API Key" 'Required
zeroBounceAPI.emailToValidate = "Email address you are validating" 'Required
zeroBounceAPI.ip_address = "IP address the email signed up with" 'Optional
'Depending on how you use the API, you might want it to time out faster, for example on a registration screen.
'Normally the API will return results very fast, but a small percentage of mail servers
'take upwards of 20+ seconds to respond.
'If the API times out, it will return a status of "Unknown" and a sub_status of "timeout_exceeded"
zeroBounceAPI.readTimeOut = 200000 'Any integer value in milliseconds
zeroBounceAPI.requestTimeOut = 150000 'Any integer value in milliseconds
Dim apiProperties = zeroBounceAPI.ValidateEmail
Dim apiCredits = zeroBounceAPI.GetCredits
'use the properties to make decisions on
Select Case (apiProperties.status)
Case "Invalid"
Console.WriteLine("Invalid")
Case "Valid"
Console.WriteLine("Valid")
Case Else
Console.WriteLine(apiProperties.status)
End Select