Parse an email with C#

Created by Paul Mendoza, Modified on Fri, 28 Oct 2022 at 08:55 AM by Paul Mendoza

Use the SigParser v3 Nuget package to parse an email with C# like the example below shows. This is using an "msg" file but you could use a ".eml" file which is just MIME or you could provide a C# object. 


using System;
using System.Diagnostics;
using SigParser.Api;
using SigParser.Client;
using SigParser.Model;


// Configure API key authorization: x-api-key
Configuration.ApiKey.Add("x-api-key", "PUT YOUR API KEY HERE");
Console.WriteLine("Starting");


try
{
    var apiInstance = new ParseApi();
    
    using var filestream = System.IO.File.OpenRead("example.msg");
    IPaasAPIModelsParseEmailSignatureV2Model result = apiInstance.ApiParseEmailContactMSGPost(filestream);
    Console.WriteLine("Finished request");
    Console.WriteLine(result);
}
catch (ApiException e)
{
    Console.WriteLine($@"Exception when calling ParseApi.ApiParseEmailContactMSGPost: {e.ErrorCode} {e.ErrorContent} 

{e.ToString()}");
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article