2016-07-08 1 views
0

EmailMessage 개체에서 첨부 파일의 이름을 바꾸려고합니다.EWS C# 첨부 파일을 업데이트 할 수 없습니다.

msg.Attachments.Where(c => c.Name == attachmentPdfFullNames[0]).FirstOrDefault().Name = "NEW NAME ATTACHMENT"; 

그러나 던져 예외 첨부를 업데이트 할 수 없습니다. 그때 제거하고 첨부 파일을 다시 추가 복사하고 이름을 변경하려고했으나 같은 :

Attachment a = msg.Attachments.Where(c => c.Name == attachmentPdfFullNames[0]).FirstOrDefault(); 
Attachment b = a; 
b.Name = "NEW NAME ATTACHMENT"; 
msg.Attachments.Remove(a); 
msg.Attachments.AddFileAttachment("./" + b.Name); 

감사

당신은 EWS에서 첨부 파일 이름을 바꿀 수 없습니다

답변

1

(이 방금 생성 할 아무런 조작이없고, 지우다). 따라서 이름을 바꾸려는 첨부 파일을 제거한 다음 다시 첨부해야합니다. 코드와

당신은 당신의 제거 후 당신이 전에 새 첨부 파일 등을

msg.Attachments.Remove(a); 
msg.Update(ConflictResolutionMode.AlwaysOverwrite); 
msg.Attachments.AddFileAttachment("./" + b.Name); 
msg.Update(ConflictResolutionMode.AlwaysOverwrite); 
+0

감사를 추가 한 후 다음 첨부 파일을 다시 추가 (코드 작업을 수행하는 것을 의미) 메시지에 대한 업데이 트를 호출 할 필요가 당신, 나는 시험 할 것이고 나는 당신에게 돌아갈 것입니다. – ArthurCPPCLI