Tutorial: How to Use an Email Verification API with C#

Using an API for email verification involves sending a GET request to the API endpoint. Here's how you can do this using C# and use the response data:

using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Collections.Generic;

class Program
    static readonly HttpClient client = new HttpClient();

    static async Task Main()
        // Set the email address and API token
        var email = "Email_Address";  // Replace with the email you want to verify
        var token = "YOUR_API_KEY";  // Replace with your actual API key

        // Form the URL
        var url = $"https://api.ValidEmail.net/?email={email}&token={token}";

        HttpResponseMessage response = await client.GetAsync(url);

        if (response.IsSuccessStatusCode)
            var responseBody = await response.Content.ReadAsStringAsync();

            // Deserialize the JSON data into a C# object
            var result = JsonConvert.DeserializeObject<Response>(responseBody);

            // Use the data
            Console.WriteLine($"Email is valid: {result.IsValid}");
            Console.WriteLine($"Score: {result.Score}");
            Console.WriteLine($"Email state: {result.State}");
            Console.WriteLine($"Reason: {result.Reason}");

            foreach (var info in result.EmailAdditionalInfo)
                Console.WriteLine($"{info.Key}: {info.Value}");
            Console.WriteLine($"Request failed with status code {response.StatusCode}");

public class Response
    public bool IsValid { get; set; }
    public int Score { get; set; }
    public string Email { get; set; }
    public string State { get; set; }
    public string Reason { get; set; }
    public string Domain { get; set; }
    public bool Free { get; set; }
    public bool Role { get; set; }
    public bool Disposable { get; set; }
    public bool AcceptAll { get; set; }
    public bool Tag { get; set; }
    public string MXRecord { get; set; }
    public List<Info> EmailAdditionalInfo { get; set; }

public class Info
    public string Key { get; set; }
    public string Value { get; set; }

Remember to replace 'Email_Address' and 'YOUR_API_KEY' with the actual email address you want to verify and your actual API key.

Note that in C#, it's important to handle any potential exceptions that might occur when sending the HTTP request, such as when the network is unavailable.