API SMTP do SendGrid: incorporar imagem: solicitação incorreta
Estou usando a API SMTP sendgridhttps://github.com/sendgrid/sendgrid-csharp para enviar e-mails, mas não consigo descobrir como incorporar uma imagem. Eu posso fazer isso usando a API nativa de email do .Net sem problemas. Estou simplesmente recebendo uma solicitação inválida. Aqui está o meu código que está jogando
private static void Main(string[] args)
{
try {
//// Create the email object first, then add the properties.
var myMessage = new SendGridMessage();
contact_list = new List<MailAddress>();
contact_list.Add(new MailAddress("email@gmail.com"));
myMessage.To = contact_list.ToArray();
myMessage.From = new MailAddress("clientservice@stpis.com");
myMessage.Subject = "Subject";
string html = "<div><img src=cid:Logo /></div>";
myMessage.Html = html;
myMessage.EmbedImage(@"C:\logo.png", "Logo");
SendMessage(myMessage);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
}
private static void SendMessage(SendGridMessage message)
{
// Create credentials, specifying your user name and password.
var credentials = new NetworkCredential("username", "pwdpwdpwd");
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
try
{
transportWeb.Deliver(message);
Console.WriteLine("Sent!");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}