Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C发送Outlook会议请求#_C#_Asp.net_Outlook - Fatal编程技术网

C# 使用C发送Outlook会议请求#

C# 使用C发送Outlook会议请求#,c#,asp.net,outlook,C#,Asp.net,Outlook,我希望从C#发送outlook会议请求。 我有下面的代码,它做的工作,但 string startTime1 = Convert.ToDateTime(startTime).ToString("yyyyMMddTHHmmssZ"); string endTime1 = Convert.ToDateTime(endTime).ToString("yyyyMMddTHHmmssZ"); SmtpClient sc = new SmtpClient(""); MailMessage msg = ne

我希望从C#发送outlook会议请求。 我有下面的代码,它做的工作,但

string startTime1 = Convert.ToDateTime(startTime).ToString("yyyyMMddTHHmmssZ");
string endTime1 = Convert.ToDateTime(endTime).ToString("yyyyMMddTHHmmssZ");
SmtpClient sc = new SmtpClient("");

MailMessage msg = new MailMessage();

msg.From = new MailAddress("", "HR Self Service");
msg.To.Add(new MailAddress(emailto));
msg.Subject = "Holiday Approval";
msg.Body = emailbody;

StringBuilder str = new StringBuilder();
str.AppendLine("BEGIN:VCALENDAR");

//PRODID: identifier for the product that created the Calendar object
str.AppendLine("PRODID:-//ABC Company//Outlook MIMEDIR//EN");
str.AppendLine("VERSION:2.0");
str.AppendLine("METHOD:REQUEST");

str.AppendLine("BEGIN:VEVENT");

str.AppendLine(string.Format("DTSTART:{0:yyyyMMddTHHmmssZ}", startTime1));//TimeZoneInfo.ConvertTimeToUtc("BeginTime").ToString("yyyyMMddTHHmmssZ")));
str.AppendLine(string.Format("DTSTAMP:{0:yyyyMMddTHHmmssZ}", DateTime.UtcNow));
str.AppendLine(string.Format("DTEND:{0:yyyyMMddTHHmmssZ}", endTime1));//TimeZoneInfo.ConvertTimeToUtc("EndTime").ToString("yyyyMMddTHHmmssZ")));
str.AppendLine(string.Format("LOCATION: {0}", "Location"));

// UID should be unique.
str.AppendLine(string.Format("UID:{0}", Guid.NewGuid()));
str.AppendLine(string.Format("DESCRIPTION:{0}", msg.Body));
str.AppendLine(string.Format("X-ALT-DESC;FMTTYPE=text/html:{0}", msg.Body));
str.AppendLine(string.Format("SUMMARY:{0}", msg.Subject));

str.AppendLine("STATUS:CONFIRMED");
str.AppendLine("BEGIN:VALARM");
str.AppendLine("TRIGGER:-PT15M");
str.AppendLine("ACTION:Accept");
str.AppendLine("DESCRIPTION:Reminder");
str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY");
str.AppendLine("END:VALARM");
str.AppendLine("END:VEVENT");

str.AppendLine(string.Format("ORGANIZER:MAILTO:{0}", msg.From.Address));
str.AppendLine(string.Format("ATTENDEE;CN=\"{0}\";RSVP=TRUE:mailto:{1}", msg.To[0].DisplayName, msg.To[0].Address));

str.AppendLine("END:VCALENDAR");
System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
ct.Parameters.Add("method", "REQUEST");
ct.Parameters.Add("name", "meeting.ics");
AlternateView avCal = AlternateView.CreateAlternateViewFromString(str.ToString(), ct);
msg.AlternateViews.Add(avCal);
//Response.Write(str);
// sc.ServicePoint.MaxIdleTime = 2;
sc.Send(msg);
发送邀请时,需要用户接受邀请,当用户接受邀请时,Outlook日历显示状态为
是否有任何方法可以发送邀请,而不要求用户接受邀请,并且Outlook日历显示为外出? 我试过这两个部分,但没有运气

str.AppendLine("ACTION:Accept");
str.AppendLine("X-MICROSOFT-CDO-BUSYSTATUS:BUSY");

如果这是一个资源邮箱,您可以将其配置为自动接受会议邀请(文件|选项|日历|自动接受或拒绝)


如果这是一个任意邮箱,未经所有者许可,任何事情都不会发生。如果您具有用户凭据,则最好使用Outlook对象模型/EWS/MAPI直接访问邮箱

这是一个结构合理的问题。但是,我无法想象Exchange会让任何旧的SMTP邮件自动接受会议请求。itsme86感谢您的评论,是否有任何新的SMTP允许我发送自动接受会议请求的电子邮件?不是SMTP,但您查看过Exchange Web服务(EWS)吗?我正试图使用此代码从控制台应用程序发送一个会议请求,该应用程序是用c#编写的,我是否应该做些什么来配置服务器,它给了我一个错误(未指定SMTP主机)@Laila您必须在第3行的空字符串中指定SMTP主机:SmtpClient sc=new SmtpClient(“”);