无法将附件添加到日历活动 [英] can't add attachment to calendar event

查看:77
本文介绍了无法将附件添加到日历活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Office 365 Starter Project for ASP.NET MVC将日历添加到日历 https: //github.com/OfficeDev/O365-ASPNETMVC-Start .由于它需要事件ID,因此无法使用方法AddCalendarEventAsync添加.因此,我尝试使用以下代码更新事件:

I am trying to add attachment to calendar using Office 365 Starter Project for ASP.NET MVC https://github.com/OfficeDev/O365-ASPNETMVC-Start. As it requires event id I can't add using method AddCalendarEventAsync. So I'm trying to update event using below code:

var outlookServicesClient = await AuthenticationHelper.EnsureOutlookServicesClientCreatedAsync("Calendar");
var thisEventFetcher = outlookServicesClient.Me.Calendar.Events.GetById(selectedEventId);
IEvent eventToUpdate = await thisEventFetcher.ExecuteAsync();

但是'eventToUpdate'没有附件设置属性.请您检查一下并解释如何向日历添加附件.

But 'eventToUpdate' has not Attachment set property. Please could you check this and explain how to add attachment to calendar.

谢谢.

推荐答案

var thisEventFetcher = outlookServicesClient.Me.Calendar.Events.GetById(eventID);
Attachment attachment = new FileAttachment
                                {
                                    Name = "test",
                                    ContentBytes = File.ReadAllBytes(@"D:\test.jpeg"),
                                    ContentType = "image/jpeg"
                                };
                                await thisEventFetcher.Attachments.AddAttachmentAsync(attachment);

这篇关于无法将附件添加到日历活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆