Sendgrid System.ArgumentException: Unknown element: html

强颜欢笑 提交于 2019-12-12 13:28:08

问题


I've just update the following packages to their latest version:

a) SendGrid.SmtpApi updated to 1.3.1

b) SendGrid update to 6.0

and suddenly the WebTransport.Deliver method is not there anymore - no problem, I've switched to DeliverAsync method but now I get a very strange error, that it's supposed to be fixed since 2 years ago:

System.ArgumentException: Unknown element: html

This is part of the stack trace that can be of interest:

System.ArgumentException: Unknown element: html

at SendGrid.ErrorChecker.CheckForErrors(HttpResponseMessage response, Stream stream)

at SendGrid.ErrorChecker.d__0.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at SendGrid.Web.d__0.MoveNext()

--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

And also this is how my email sending code looks like:

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>()
                {
                    String.Format("{2}{0}{1}", user.CompleteRegistrationModel.CompanyUrlPrefix,
                        ConfigurationHelper.DomainSuffix, ConfigurationHelper.ApplicationAccessProtocol)
                });
            emailMessage.AddSubstitution("-username-",
                new List<string>() {user.CompleteRegistrationModel.UserEmailAddress});
            emailMessage.AddSubstitution("-confirmationurl-",
                new List<string>() {user.CompleteRegistrationModel.UserEmailAddressConfirmationCompleteUrl});

            emailMessage.Subject = String.Format("{0}{1}", user.CompleteRegistrationModel.CompanyUrlPrefix,
                ConfigurationHelper.DomainSuffix);
            emailMessage.Text = " ";
            emailMessage.Html = " ";

            Web webTransport =
                new Web(new NetworkCredential(ConfigurationHelper.SendgridUsername,
                    ConfigurationHelper.SendgridPassword));

            try
            {
                await webTransport.DeliverAsync(emailMessage);
            }
            catch (InvalidApiRequestException exception)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(exception);
            }

Can, please, someone tell me what is happening?

Thank you, Evdin


回答1:


Please update to 6.0.1, there was a bug in 6.0.0 and it was unlisted. Thanks.

https://github.com/sendgrid/sendgrid-csharp/blob/master/CHANGELOG.md



来源:https://stackoverflow.com/questions/29876448/sendgrid-system-argumentexception-unknown-element-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!