我正在尝试发送电子邮件并收到此错误
无法将类型“System.Net.Mail.MailAddress”隐式转换为“SendGrid.Helpers.Mail.EmailAddress”
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new MailAddress("[email protected]", "My name");//here the error Happens
myMessage.Subject = message.Subject;
myMessage.PlainTextContent = message.Body;
myMessage.HtmlContent= message.Body;
您刚刚犯了一个小错字。
改变
myMessage.From = new MailAddress("[email protected]", "My name")
到
myMessage.From = new EmailAddress("[email protected]", "My name")
^
发送网格错误:
无法从“System.Net.Mail.MailAddress”转换为 '字符串'WindowsServiceCG
添加方法
EmailAddress
而不是 MailAddress
。
SendGridMessage message = new SendGridMessage();
message.AddBcc(new EmailAddress("Your Email Address", "personalization msg"));