.ics日历。通过电子邮件API电子邮件发送方法预约

时间:2017-10-12 15:25:29

标签: c# asp.net email icalendar

大家好我正在创建一个创建类似约会的事件的系统。然后使用This method

通过电子邮件将其发送给接收者

它会像这样创建一个日历。

  string[]  contents = { "BEGIN:VCALENDAR",
                          "PRODID:-//Flo Inc.//FloSoft//EN",
                          "BEGIN:VEVENT",
                          "DTSTART:" + schBeginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
                          "DTEND:" + schEndDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
                          "LOCATION:" + schLocation,
                          "ORGANIZER:" + "Haseeb",
                     "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + schDescription,
                          "SUMMARY:" + schSubject, "PRIORITY:3",
                     "END:VEVENT", "END:VCALENDAR" };

System.IO.File.WriteAllLines(Server.MapPath("Calendar's//" + txtCelenderName.Text + ".ics"),
contents);

它运作良好并发送电子邮件,但每次创建一个事件时,它下载一个文件,这是一个大数据,一个有400个用户的公司和与客户的会议将会过载。是否有任何其他方法来发送日历提醒而不将其保存到路径中。 这就是我发送附件的方式。

RestClient client = new RestClient();
client.BaseUrl = new Uri("https://api.mailgun.net");
client.Authenticator = new HttpBasicAuthenticator("api", "key-key");

RestRequest request = new RestRequest();
request.AddParameter("domain", "email.com", ParameterType.UrlSegment);
request.Resource = "{domain}/messages";

if (!string.IsNullOrEmpty(sFromAlias))
    request.AddParameter("from", sFromAlias + " <" + sFrom + ">");
else
    request.AddParameter("from", "<" + sFrom + ">");

request.AddParameter("subject", sSubject);
request.AddParameter("html", sBody);
request.AddFile("attachment", Path, "text/calendar"); // This is the Celender that goes along the Email 
request.Method = Method.POST;

0 个答案:

没有答案