How to validate an EML Email File in C# .NET Framework

Cloudmersive
1 min readJul 26, 2020

Email validation is a highly underrate feature that can really save you from a storm of headaches down the line. However, validating this format isn’t always easy, as there are many components that need to be checked. To make this simple, we will be making use of a Cloudmersive API that can validate your EML files without any problems.

First we install the package for our API client:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Now for our function call.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ValidateDocumentEmlValidationExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ValidateDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Validate if an EML file is executableDocumentValidationResult result = apiInstance.ValidateDocumentEmlValidation(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ValidateDocumentApi.ValidateDocumentEmlValidation: " + e.Message );}}}}

And that’s already done with.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.