У кого-нибудь есть идеи как этого добиться? TestDataPdf начинается с data:application/pdf;filename=generated.pdf;base64,
, и в результате я удаляю подстроку.
public static IRestResponse SendEmail(Nurse newNurse)
{
byte[] bytes = System.Convert.FromBase64String(newNurse.TestDataPdf.Substring(51));
var apiKey = Environment.GetEnvironmentVariable("MAIL-GUN");
RestClient client = new RestClient();
client.BaseUrl = new Uri("https://api.mailgun.net/v3");
client.Authenticator =
new HttpBasicAuthenticator("api",
"xxxxxx");
RestRequest request = new RestRequest();
request.AddParameter("domain", "xxxx", ParameterType.UrlSegment);
request.Resource = "{domain}/messages";
request.AddParameter("from", "<test@test.com>");
request.AddParameter("to", $"{newNurse.RecruiterEmail}");
request.AddParameter("subject", "New Skills Assessment Test");
request.AddParameter("application/pdf", bytes, ParameterType.RequestBody);
request.AddParameter("text", "test");
// request.AddParameter("application/pdf", bytes, ParameterType.RequestBody);
// request.AddFile("attachment", Path.Combine(pdflocation, fileName));
request.Method = Method.POST;
return client.Execute(request);