so I finished developping a CRM web app but still have a problem verifying if a given email exists or not, so I googled if some free apis exists and found one but i couldn't integrate it's code in my app as it's writin in .net but i am using .net core, So here's the code:
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Web.Script.Serialization;
namespace PermissionManagement.MVC
{
public class APIResult
{
private class APIResults
{
public int status { get; set; }
public string info { get; set; }
public string details { get; set; }
}
public void Checkemail(string mail)
{
const String APIURL = "https://api.email-validator.net/api/verify";
HttpClient client = new HttpClient();
String Email = mail;
String APIKey = "hidden";
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("EmailAddress", Email));
postData.Add(new KeyValuePair<string, string>("APIKey", APIKey));
HttpContent content = new FormUrlEncodedContent(postData);
HttpResponseMessage result = client.PostAsync(APIURL, content).Result;
string resultContent = result.Content.ReadAsStringAsync().Result;
// HERE IS THE ERROR
APIResults res = new JavaScriptSerializer().
Deserialize<APIResult>(resultContent);
switch (res.status)
{
// valid addresses have a {200, 207, 215} result code
// result codes 114 and 118 need a retry
case 200:
case 207:
case 215:
// address is valid
// 215 - can be retried to update catch-all status
break;
case 114:
// greylisting, wait 5min and retry
break;
case 118:
// api rate limit, wait 5min and retry
break;
default:
// address is invalid
// res.info
// res.details
break;
}
}
}
}
I marked the error with a comment as you can see and also it keeps showing an error in the using statement (using System.Web.Script.Serialization;)
Can anyone help me convert it so I can use it