You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the SendGrid Web API V3 SDK version with .NET Framework 4.5.2. I am using the SendGrid Dll version 9.1.0 for it.
Below is the code that is working fine.
var apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_APIKEY");
var client = new SendGridClient(apiKey);
var msg = new SendGridMessage()
{
From = new EmailAddress("[email protected]", "SendGrid Team"),
Subject = "Hello World from the SendGrid CSharp SDK!",
PlainTextContent = "Hello, Email!",
HtmlContent = @"<strong>Dear Valued Customer</strong>"
};
msg.AddTo(new EmailAddress("[email protected]", "Sendgrid poc"));
//Add this block of code for attachment - START
List<Attachment> itms = new List<Attachment>();
Attachment itm;
Attachment itm = new Attachment();
itm.Filename = "test";
itm.Content = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAQAAABLCVATAAACH0lEQVR42q3WoZKrMBQGYGRkIpHEoY9DMrh1nUGtzxPcGV7gCsTaK3iBCqa2ipmrVqLrWrmytjL3nBwoEGD30ja/6JaSj/wp3SEIXjpUoB+Oeg0zpoR+NsyoDVOgi39cbYHAy4MQTc0wOYZepxRBUkn9UxxEiNnXxyYwd6w/438hSddHJilv1tqv664Shle1DeJaJihPV9uNQ+NWBRK2QVSr+GjtaFzOIpdjKFShnoY+Gv0N0u0OVLexY48NQ+68JchdpQu/o1piVMu6faJdwjNWIAYyl55bqGUtbndO53TzCIpUpCkdlEm+V3J3Ir8r3uops2+FkTmvx832IGJwN97xS/5Ti0LQ/WLwtbxMal2ueAwvc2c8CAgSJip5U4+tKHECMlUzq2UcA9EyROuJi6/71dtzWAfVcq0Jw1CsYh13kDDteVoirE+zWtLVinQ8ZAS5YlVlvRHWfi3pakUQL0OOwmp/W/vN6Gt5zBIkzEezxnCtMJsxDIECTYmhp3bej4HHzaalNMyAnzE0UBKp6Z1Do2pwd3JkAH6CxlTs/bZOZ661yMwhohDLQqREMWz8UAvWoUQleggehG5dSPUbv28GJlnKHGJsqPi7vuG/MGTyCGslOtkCOayrGOa/indajdudb6FUpXoepgiLHIIMriddyzrkMBhGAqlOH4U2hKCT2j0NdU8jFbzpZ3LQlh9srPqEQ1Y9lEP2CVa99KHvH8mnrGGdl9V9AAAAAElFTkSuQmCC";
itm.ContentId = "1";
itm.Disposition = "attachment";
itm.Type = "image/jpeg";
itms.Add(itm);
msg.AddAttachments(itms);
//Add this block of code for attachment - END
var response = await client.SendEmailAsync(msg);
emailStatusCode = response.StatusCode.ToString();
if (HttpStatusCode.Accepted == response.StatusCode)
{
//mail sent
}
else
{
//mail not sent; for any reason
}
Steps to Reproduce
I had changed valid from email ([email protected]) to invalid from email(from@example) and forgot this change.
Then, I implemented the code for the adding the attachment.
Now, when I run the code to send the attachment, I get the "BadRequest" in response as a status code.
I forgot about the from email address changes and I was thinking that I`m doing something wrong in attachment coding. This wasted my whole day.
So, for this scenario I have few questions.
Is there any way to get or track the error details in the above code? It will really help me in saving the development time.
If there as any code, could you please share with me.
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
Hi Team,
I am using the SendGrid Web API V3 SDK version with .NET Framework 4.5.2. I am using the SendGrid Dll version 9.1.0 for it.
Below is the code that is working fine.
Steps to Reproduce
I forgot about the from email address changes and I was thinking that I`m doing something wrong in attachment coding. This wasted my whole day.
So, for this scenario I have few questions.
Technical details:
The text was updated successfully, but these errors were encountered: