简体   繁体   中英

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

I try to add an inline attachment to an appointment through web services for exchange 2010. I followed the steps described in this article (even though it describes email attachments), and it does not work: http://msdn.microsoft.com/en-us/library/hh532564(v=exchg.80).aspx . The attachment IS added to the appointment, but I do not get it to show in the body; I always get an empty space.

This is my code just copying an .jpg attachment from one appointment to another one:

// 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);

To clarify: I tried the method on email messages, and that works. Just appointments do not.

According to this example you should set HasAttachments property too.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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