gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 16:06:13 27 4
gpt4 key购买 nike

我尝试通过 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);

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

最佳答案

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

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

关于c# - EWS(Exchange Web 服务)- 向约会添加内联附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19241300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com