通过iCal文件的电子邮件邀请 [英] Email invitation via an iCal file

查看:187
本文介绍了通过iCal文件的电子邮件邀请的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直停留在这个问题上几个小时在这一点上,我无法弄清楚这个问题。



我想发电子邮件(Gmail的)的通过iCal文件的邀请,



它的工作原理(reciever可以得到一个邀请,并可以点击是添加这一邀请
reciever的日历),如果我发送一个事件



但它的失败(在Gmail将仅仅只显示一个邀请,如果我点击是的,我想将它添加到我的日历,它只有一个邀请加入。我的日历),如果我派两个事件



中的代码如下:

 保护无效的Page_Load(对象发件人,EventArgs五)
{


味精MAILMESSAGE新= MAILMESSAGE(testxxx@gmail.com,的testXXX @ gmail的。 COM,测试,测试);

msg.IsBodyHtml = TRUE;

SmtpClient SMTP =新SmtpClient(smtp.gmail.com,587);

smtp.Credentials =新的NetworkCredential(测试,测试);

味精= GetCalanderInviteMsg3(MSG);

smtp.EnableSsl = TRUE;

smtp.Send(MSG);
}

公共静态MAILMESSAGE GetCalanderInviteMsg3(MSG MAILMESSAGE)
{


StringBuilder的SB =新的StringBuilder();
sb.AppendLine(BEGIN:VCALENDAR);
sb.AppendLine(PRODID: - //谷歌公司//谷歌日历70.9054 // EN);
sb.AppendLine(版本:2.0);
sb.AppendLine(CALSCALE:GREGORIAN);
sb.AppendLine(方法:发布);
sb.AppendLine(X-WR-CALNAME:测试);
sb.AppendLine(X-WR-区:亚洲/台北);
sb.AppendLine(X-WR-CALDESC:);
sb.AppendLine(BEGIN:VEVENT);
sb.AppendLine(DTSTART; VALUE = DATE:20130705)`
sb.AppendLine(DTEND; VALUE = DATE:20130706);
sb.AppendLine(DTSTAMP:20130127T040705Z);
sb.AppendLine(UID:+c643b569-9ba8-45c1-9264-8f160411872a);
sb.AppendLine(生成:20130624T082605Z);
sb.AppendLine(描述:);
sb.AppendLine(最后一次修改:+2013127T054310Z);
sb.AppendLine(位置:);
sb.AppendLine(顺序:0);
sb.AppendLine(状态:Confirmed);
sb.AppendLine(摘要:EVENT1);
sb.AppendLine(TRANSP:透明);
sb.AppendLine(END:VEVENT);
sb.AppendLine(BEGIN:VEVENT);
sb.AppendLine(DTSTART; VALUE = DATE:20130703);
sb.AppendLine(DTEND; VALUE = DATE:20130704);
sb.AppendLine(DTSTAMP:20130127T040730Z);
sb.AppendLine(UID:+84395bf9-875e-4925-864f-910309e0a355);
sb.AppendLine(生成:20080624T082556Z);
sb.AppendLine(描述:);
sb.AppendLine(最后一次修改:+2013127T054320Z);
sb.AppendLine(位置:);
sb.AppendLine(顺序:0);
sb.AppendLine(状态:Confirmed);
sb.AppendLine(摘要:EVENT2);
sb.AppendLine(TRANSP:透明);
sb.AppendLine(END:VEVENT);
sb.AppendLine(END:VCALENDAR);
System.Net.Mime.ContentType克拉=新System.Net.Mime.ContentType(文本/日历);
ct.Parameters.Add(法,请求);
AlternateView avCal = AlternateView.CreateAlternateViewFromString(sb.ToString(),CT);
msg.AlternateViews.Add(avCal);

返回味精;
}


解决方案

这个问题是不是与你代码(尽管不同的uid是强制性的,因为每rfc5545),但与从不同的日历应用程序的GUI。



如果我们伸出您的使用情况下,他们可能是潜在的100的或电子邮件中的事件和GUI应该怎么样子的1000年? 100的或一系列的按钮1000年被点击每个单独的事件?



所以eventhough你的代码是正确的,并且IMIP(RFC6047)也说,超过1 VEVENT可包括在内,这是不好的做法,因为用户需要批准逐一将有超过1个事件。



如果你想要的是有2 <$ C同一事件(因此相同的UID),你应该使用RDATE属性一个事件来指定两个日期,然后用户可以接受的$ C>实例的邀请1个事件(这将有2个实例)。


I've been stuck on this problem for hours at this point and I can't figure out the problem.

I would like to email(gmail) an invitation through an iCal file,

It works(reciever can get a invitation and can click yes to add this invitation to reciever's calendar) if I send one event,

but its failed(the gmail will just only show an invitation , and if i click yes that i want to add it to my calendar, its only add one invitation to my calendar) if I send two events.

The code is the following:

protected void Page_Load(object sender, EventArgs e)
{


    MailMessage msg = new MailMessage("testxxx@gmail.com", "testxxx@gmail.com", "test", "test");

    msg.IsBodyHtml = true;

    SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

    smtp.Credentials = new NetworkCredential("test", "test");

    msg = GetCalanderInviteMsg3(msg);

    smtp.EnableSsl = true;

    smtp.Send(msg);
}

public static MailMessage GetCalanderInviteMsg3(MailMessage msg)
{    


    StringBuilder sb = new StringBuilder();
    sb.AppendLine("BEGIN:VCALENDAR");
    sb.AppendLine("PRODID:-//Google Inc//Google Calendar 70.9054//EN");
    sb.AppendLine("VERSION:2.0");
    sb.AppendLine("CALSCALE:GREGORIAN");
    sb.AppendLine("METHOD:PUBLISH");
    sb.AppendLine("X-WR-CALNAME:test");
    sb.AppendLine("X-WR-TIMEZONE:Asia/Taipei");
    sb.AppendLine("X-WR-CALDESC:");
    sb.AppendLine("BEGIN:VEVENT");
    sb.AppendLine("DTSTART;VALUE=DATE:20130705")`
    sb.AppendLine("DTEND;VALUE=DATE:20130706");
    sb.AppendLine("DTSTAMP:20130127T040705Z");
    sb.AppendLine("UID:" + "c643b569-9ba8-45c1-9264-8f160411872a");
    sb.AppendLine("CREATED:20130624T082605Z");
    sb.AppendLine("DESCRIPTION:");
    sb.AppendLine("LAST-MODIFIED:" + "2013127T054310Z");
    sb.AppendLine("LOCATION:");
    sb.AppendLine("SEQUENCE:0");
    sb.AppendLine("STATUS:CONFIRMED");
    sb.AppendLine("SUMMARY:event1");
    sb.AppendLine("TRANSP:TRANSPARENT");
    sb.AppendLine("END:VEVENT");
    sb.AppendLine("BEGIN:VEVENT");
    sb.AppendLine("DTSTART;VALUE=DATE:20130703");
    sb.AppendLine("DTEND;VALUE=DATE:20130704");
    sb.AppendLine("DTSTAMP:20130127T040730Z");
    sb.AppendLine("UID:" + "84395bf9-875e-4925-864f-910309e0a355");
    sb.AppendLine("CREATED:20080624T082556Z");
    sb.AppendLine("DESCRIPTION:");
    sb.AppendLine("LAST-MODIFIED:" + "2013127T054320Z");
    sb.AppendLine("LOCATION:");
    sb.AppendLine("SEQUENCE:0");
    sb.AppendLine("STATUS:CONFIRMED");
    sb.AppendLine("SUMMARY:event2");
    sb.AppendLine("TRANSP:TRANSPARENT");
    sb.AppendLine("END:VEVENT");
    sb.AppendLine("END:VCALENDAR");
    System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType("text/calendar");
    ct.Parameters.Add("method", "REQUEST");
    AlternateView avCal = AlternateView.CreateAlternateViewFromString(sb.ToString(), ct);
    msg.AlternateViews.Add(avCal);

    return msg;
}

解决方案

the problem is not with your code (though a different uid is mandatory as per rfc5545), but with the GUI from the different calendar application.

if we stretch your use case, their could be potentially 100's or 1000's of events in an email and how should the GUI look like? 100's or 1000's of buttons in series to be clicked for each individual event?

so eventhough your code is correct and the iMIP (RFC6047) also says more than 1 VEVENT can be included, it is not good practice to have more than 1 event as the user needs to approve them one by one.

if what you want is to have 2 instances of the same event (hence the same UID), you should use the RDATE property to specify your 2 dates in one EVENT and then your user can accept the invite for 1 event (which will have 2 instances).

这篇关于通过iCal文件的电子邮件邀请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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