繁体   English   中英

EWS(Exchange Web服务)-向约会添加内联附件

[英]EWS (Exchange Web Services) - Add inline attachment to appointment

我尝试通过Web服务为Exchange 2010向约会添加内联附件。我遵循了本文中描述的步骤(即使它描述了电子邮件附件),但它不起作用: http : //msdn.microsoft.com/ zh-cn / 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);

澄清一下:我尝试了电子邮件方法,并且行得通。 只是约会而已。

根据此示例,您还应该设置HasAttachments属性。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM