如何使用EWS将文件附件添加到约会?
问题描述:
我正在开发使用EWS托管API向Outlook收件人发送约会的应用程序, 现在需要向约会添加附件,我可以将附件附加到电子邮件,但是当我使用与附加项目附件相同的技术时电子邮件,但附件不附加,我的代码如下如何使用EWS将文件附件添加到约会?
public string sendCalanderEvntAsReply(EntityLayer.Data_Contracts.AppointmentDTO appointment)
{
Appointment app = new Appointment(service);
app.Subject = appointment.Subject;
app.Body = appointment.Body;
app.Start = Convert.ToDateTime(appointment.Start);
app.End = Convert.ToDateTime(appointment.End);
app.Location = appointment.Location;
foreach (string obj in appointment.Attendees)
{
app.RequiredAttendees.Add(obj);
}
if (appointment.Attachments != null &&
appointment.Attachments.Count > 0)
{
foreach (var att in appointment.Attachments)
{
app.Attachments.AddFileAttachment(att.FileName);
}
}
app.Save(SendInvitationsMode.SendToAllAndSaveCopy);
}
有没有问题在我的代码? 请帮忙。
感谢
答
随着EWS当你想送你需要先保存预约您发送其他消息之前,你将只能得到固定的业主与您的代码复制这样的会议邀请函的附件您应使用类似
Appointment app = new Appointment(service);
app.Subject = appointment.Subject;
app.Body = appointment.Body;
app.Start = Convert.ToDateTime(appointment.Start);
app.End = Convert.ToDateTime(appointment.End);
app.Location = appointment.Location;
if (appointment.Attachments != null &&
appointment.Attachments.Count > 0)
{
foreach (var att in appointment.Attachments)
{
app.Attachments.AddFileAttachment(att.FileName);
}
}
app.Save(SendInvitationsMode.SendToNone);
foreach (string obj in appointment.Attendees)
{
app.RequiredAttendees.Add(obj);
}
app.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
谢谢@格兰它的工作.. – Roshan
我有一个类似的问题,当删除附件和添加新的。但是这个解决方案对我不起作用。这里是我的情况,如果你可能有一瞥:https://stackoverflow.com/questions/48658409/how-to-update-delete-file-attachments-to-appointment-using-ews –