发送带有EWS附件的电子邮件时的错误 - ServicerSponseException-可以执行操作,因为该项目已过时

发布于 2025-02-01 13:10:18 字数 2208 浏览 2 评论 0原文

我们将EWS服务附件带有Follwing Code的电子邮件发送

EmailMessage message = new EmailMessage(ExchangeServiceController);

EmailAddress sender = new EmailAddress
{
 MailboxType = MailboxType.Mailbox,
 Address = senderAdress
};

message.From = sender;
message.ToRecipients.AddRange(email.SendTo.GetEmailAdressRange());
message.Subject = email.Subject;
message.Body = new MessageBody(BodyType.HTML, emailText);
                
string[] fileEntries = SignatureController.GetSignatureImagesFiles();
int i = 0;

foreach (string fileName in fileEntries.Where(f => f.Contains("image")))
{
 FileInfo info = new FileInfo(fileName);

 message.Attachments.AddFileAttachment(info.Name, fileName);
 message.Attachments[i].IsInline = true;
 message.Attachments[i].ContentId = info.Name;
 i++;
}

foreach (string filename in GetAttachmentsAsFilePathList())
{
 message.Attachments.AddFileAttachment(filename);
}

var mailbox = new Mailbox(sender.Address);
var folderIdDrafts = new FolderId(WellKnownFolderName.Drafts, mailbox);
var folderIdSent = new FolderId(WellKnownFolderName.SentItems, mailbox);

// save email at draft to get the mime-content
message.Save(folderIdDrafts);
message.Load(new PropertySet(ItemSchema.MimeContent));
email.EmlContent = message.MimeContent;

if (template.SaveMessageOnSend)
{
 message.SendAndSaveCopy(folderIdSent);
}
else
{
 message.Send();
}

。之后,我们有时会遇到一个错误的错误...

类型:microsoft.exchange.webservices.data.serviceresponseexception 资料来源:Microsoft.exchange.webservices 消息:由于该项目已过时,因此无法执行操作。重新加载项目,然后重试。 Hresult:-2146233088(0x80131500) Innerexception:null 哈希签名:49E2BF981546C920B6A4BC0B27476A40 StackTrace: bei microsoft.exchange.webservices.data.serviceresponse.internalthrowifnequestares() bei microsoft.exchange.webservices.data.multerponseservicerequest`1.execute() bei Microsoft.exchange.webservices.data.exchangeservice.senditem(项目项目,folderid savedcopydestinationfolderId) bei Microsoft.exchange.webservices.data.emailmessage.internalsend(folderid parentfolderid,messagedisposition messagedisposition)

经常发生在6 MB上的附件时。

超过1分钟,此时间在此之前的错误。

MaxSize超过10 MB

当我在Outlook上获取此电子邮件并将其从草案发送正常运行时,

。有人想解决这个问题吗?

最好的问候史蒂夫

we send emails with attachments by the ews-service with the follwing code...

EmailMessage message = new EmailMessage(ExchangeServiceController);

EmailAddress sender = new EmailAddress
{
 MailboxType = MailboxType.Mailbox,
 Address = senderAdress
};

message.From = sender;
message.ToRecipients.AddRange(email.SendTo.GetEmailAdressRange());
message.Subject = email.Subject;
message.Body = new MessageBody(BodyType.HTML, emailText);
                
string[] fileEntries = SignatureController.GetSignatureImagesFiles();
int i = 0;

foreach (string fileName in fileEntries.Where(f => f.Contains("image")))
{
 FileInfo info = new FileInfo(fileName);

 message.Attachments.AddFileAttachment(info.Name, fileName);
 message.Attachments[i].IsInline = true;
 message.Attachments[i].ContentId = info.Name;
 i++;
}

foreach (string filename in GetAttachmentsAsFilePathList())
{
 message.Attachments.AddFileAttachment(filename);
}

var mailbox = new Mailbox(sender.Address);
var folderIdDrafts = new FolderId(WellKnownFolderName.Drafts, mailbox);
var folderIdSent = new FolderId(WellKnownFolderName.SentItems, mailbox);

// save email at draft to get the mime-content
message.Save(folderIdDrafts);
message.Load(new PropertySet(ItemSchema.MimeContent));
email.EmlContent = message.MimeContent;

if (template.SaveMessageOnSend)
{
 message.SendAndSaveCopy(folderIdSent);
}
else
{
 message.Send();
}

The email saved in draft. After this we get sometimes an follwoing error...

Type: Microsoft.Exchange.WebServices.Data.ServiceResponseException
Source: Microsoft.Exchange.WebServices
Message: The operation can't be performed because the item is out of date. Reload the item and try again.
HResult: -2146233088 (0x80131500)
InnerException: null
HashedSignature: 49E2BF981546C920B6A4BC0B27476A40
StackTrace:
bei Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
bei Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
bei Microsoft.Exchange.WebServices.Data.ExchangeService.SendItem(Item item, FolderId savedCopyDestinationFolderId)
bei Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition)

It happens often with attachment over 6 MB.

The timeout is over 1 minute and the error becomes before this time.

The maxsize is over 10 MB

When i take this email at outlook and send it from the draft it works fine.

Have anybody an idea to solve this problem?

best regards steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野鹿林 2025-02-08 13:10:18

出现错误的原因是,在提交消息时,更改键是陈旧的。如果另一个客户对消息或商店级别进行修改,则可能会发生这种情况。 -Reference/itemID?redirectedfrom = msdn“ rel =“ nofollow noreferrer”> https://learn.microsoft.com/en-us/exchange/client-develiceer/web-service-referender/werediremit?rediredirectedfrom=mmsdn 。使用该行,

message.Load(new PropertySet(ItemSchema.MimeContent));

这将迫使Exchange商店做一个消息将消息转换为Mime。我会在发送消息之前尝试进行另一次负载,然后要求提供

message.Load(new PropertySet(ItemSchema.MimeContent));
email.EmlContent = message.MimeContent;
message.Load(new PropertySet(BasePropertySet.IdOnly));

以确保您在发送之前拥有最新更改的偶像性,否则您可能只能使用MailKit之类的东西构建Mime消息,然后将其发送到一个操作中,而不是将其发送到一个操作中保存草稿。

The reason you get the error is because the changekey is stale at the time you submit the message. This can happen if another client makes a modification on the message or Store level AV can do it see changekey in https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/itemid?redirectedfrom=MSDN. With the line

message.Load(new PropertySet(ItemSchema.MimeContent));

This will be forcing the Exchange Store to do an one the fly conversion of the Message to Mime. I'd would try doing another load before sending the message and just ask for the IdOnly

message.Load(new PropertySet(ItemSchema.MimeContent));
email.EmlContent = message.MimeContent;
message.Load(new PropertySet(BasePropertySet.IdOnly));

That should ensure you have the latest changekey before send, otherwise you could probably just build the MIME message with something like MailKit and send it in one operation rather then saving the draft.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文