我尝试通过Exchange 2010的Web服务为约会添加内联附件。我按照本文中描述的步骤(即使它描述了电子邮件附件),但它不起作用:http://msdn.microsoft.com/en-us/library/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);
澄清一下:我在电子邮件中尝试了这种方法,这很有效。只是约会没有。
答案 0 :(得分:0)
根据这个例子,你也应该设置HasAttachments属性。
http://www.independentsoft.de/exchangewebservices/tutorial/createinlineattachment.html