发送电子邮件时,我在Message.Body.BodyType中收到错误:您必须先加载或指定此属性,然后才能读取其值
if (service != null)
{
Microsoft.Exchange.WebServices.Data.EmailMessage message = new Microsoft.Exchange.WebServices.Data.EmailMessage(service);
message.Subject = SendMail.Subject;
if (SendMail.IsHtml)
{
message.Body.BodyType = Microsoft.Exchange.WebServices.Data.BodyType.HTML;
message.Body = new Microsoft.Exchange.WebServices.Data.MessageBody(SendMail.Html);
}
}
答案 0 :(得分:0)
您应该使用MessageBody Overload中的BodyType参数来设置BodyType,例如
if (service != null)
{
Microsoft.Exchange.WebServices.Data.EmailMessage message = new Microsoft.Exchange.WebServices.Data.EmailMessage(service);
message.Subject = SendMail.Subject;
if (SendMail.IsHtml)
{
message.Body = new Microsoft.Exchange.WebServices.Data.MessageBody(Microsoft.Exchange.WebServices.Data.BodyType.HTML,SendMail.Html);
}
}
这应该有效,您尝试使用的属性仅在阅读现有消息时有用。
干杯 格伦