Tag: sendgrid

Sendgrid System.ArgumentException:未知元素:html

我刚刚将以下软件包更新到最新版本: a)SendGrid.SmtpApi已更新至1.3.1 b)SendGrid更新到6.0 突然间WebTransport.Deliver方法不再存在 – 没问题,我已经切换到DeliverAsync方法,但现在我得到一个非常奇怪的错误,它应该在2年前修复: System.ArgumentException:未知元素:html 这是可能感兴趣的堆栈跟踪的一部分: System.ArgumentException:未知元素:html 在SendGrid.ErrorChecker.CheckForErrors(HttpResponseMessage响应,流媒体流) 在SendGrid.ErrorChecker.d__0.MoveNext() —从抛出exception的先前位置开始的堆栈跟踪结束— 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在SendGrid.Web.d__0.MoveNext() —抛出exception的前一个位置的堆栈跟踪结束—在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 这也是我的电子邮件发送代码的样子: SendGridMessage emailMessage = new SendGridMessage(); emailMessage.AddTo(user.CompleteRegistrationModel.UserEmailAddress); emailMessage.From = new MailAddress(ConfigurationHelper.EmailSenderAddress, ConfigurationHelper.EmailSenderName); emailMessage.EnableTemplateEngine(ConfigurationHelper.ConfirmationEmailTemplateId); emailMessage.AddSubstitution(“-urlaplicatie-“, new List() { String.Format(“{2}{0}{1}”, user.CompleteRegistrationModel.CompanyUrlPrefix, ConfigurationHelper.DomainSuffix, ConfigurationHelper.ApplicationAccessProtocol) }); emailMessage.AddSubstitution(“-username-“, new List() {user.CompleteRegistrationModel.UserEmailAddress}); emailMessage.AddSubstitution(“-confirmationurl-“, new List() {user.CompleteRegistrationModel.UserEmailAddressConfirmationCompleteUrl}); emailMessage.Subject = String.Format(“{0}{1}”, user.CompleteRegistrationModel.CompanyUrlPrefix, ConfigurationHelper.DomainSuffix); emailMessage.Text = ” “; […]

SendGrid在发送电子邮件时抛出InvalidApiRequestException

SendGrid在发送电子邮件时抛出InvalidApiRequestException 。 我正在使用此代码: public Task SendEmailAsync(string email, string subject, string message) { // Plug in your email service here to send an email. var myMessage = new SendGrid.SendGridMessage(); myMessage.AddTo(email); myMessage.From = new MailAddress(“varshney@shobhit.com”, “Shobhit”, System.Text.Encoding.Default); myMessage.Subject = subject; myMessage.Text = message; myMessage.Html = message; var credentials = new NetworkCredential( Options.SendGridUser, Options.SendGridKey); // Create a Web […]

来自MemoryStream的AddAttachment

SendGrid API文档指定您可以从Stream添加附件。 它给出的示例使用FileStream对象 。 我在Azure存储中有一些blob,我想将其作为附件发送电子邮件。 要实现这一点,我正在尝试使用MemoryStream : var getBlob = blobContainer.GetBlobReferenceFromServer(fileUploadLink.Name); if(getBlob != null) { // Get file as a stream MemoryStream memoryStream = new MemoryStream(); getBlob.DownloadToStream(memoryStream); emailMessage.AddAttachment(memoryStream, fileUploadLink.Name); } emailTransport.Deliver(emailMessage); 它发送正常,但当电子邮件到达时,附件似乎在那里,但它实际上是空的。 查看电子邮件来源,附件没有内容。 在使用SendGrid C#API发送附件时,使用MemoryStream是一个已知的限制吗? 或者我应该以其他方式接近这个?

如何通过API C#和Template将自定义变量添加到SendGrid电子邮件中

我试图弄清楚如何将变量添加到已在sendgrid模板引擎中创建的现有模板(例如:动态链接或名称),我不确定如何使用SendGrid C#.NET库执行此操作。 我想知道是否有人可以帮助我。 // Create the email object first, then add the properties. SendGridMessage myMessage = new SendGridMessage(); myMessage.AddTo(“test@test.com”); myMessage.From = new MailAddress(“test@test.com”, “Mr test”); myMessage.Subject = ” “; var timestamp = DateTime.Now.ToString(“HH:mm:ss tt”); myMessage.Html = ” “; myMessage.EnableTemplate(” Hello”); myMessage.EnableTemplateEngine(“9386b483-8ad4-48c2-9ee3-afc7618eb56a”); var identifiers = new Dictionary(); identifiers[“USER_FULLNAME”] = “Jimbo Jones”; identifiers[“VERIFICATION_URL”] = “www.google.com”; myMessage.AddUniqueArgs(identifiers); // […]