2

我尝试通过 web 服务为 Exchange 2010 添加一个内联附件。我按照本文中描述的步骤进行操作(即使它描述了电子邮件附件),但它不起作用:http: //msdn.microsoft.com/ zh-CN/图书馆/hh532564(v=exchg.80).aspx。附件已添加到约会中,但我没有将其显示在正文中;我总是得到一个空的空间。

这是我的代码,只是将 .jpg 附件从一个约会复制到另一个约会:

// load the first attachment as stream
MemoryStream stream = new MemoryStream();
FileAttachment fileAttachment = (FileAttachment)appointment.Attachments[0];
fileAttachment.Load(stream);

// create new appointment
Appointment newAppointment = new Appointment(service);
string body = string.Format(@"<html>
                 <head>
                 </head>
                 <body>
                    <img width=100 height=100 id=""1"" src=""cid:{0}"">
                 </body>
                 </html>", "test.jpg");
newAppointment.Body = new MessageBody(BodyType.HTML, body);

// add the attachment to the appointment
byte[] bytes = stream.ToArray();
newAppointment.Attachments.AddFileAttachment("test.jpg", bytes);
newAppointment.Attachments[0].IsInline = true;
newAppointment.Attachments[0].ContentId = "test.jpg";

// save the appointment
FolderId folderId_Calendar = new FolderId(WellKnownFolderName.Calendar, emailAddress);
newAppointment.Save(folderId_Calendar, SendInvitationsMode.SendToNone);

澄清一下:我在电子邮件消息上尝试了该方法,并且有效。只是约会没有。

4

1 回答 1

0

根据这个例子,你也应该设置 HasAttachments 属性。

http://www.independentsoft.de/exchangewebservices/tutorial/createinlineattachment.html

于 2013-10-08T19:08:51.427 回答