大家好我正在创建一个创建类似约会的事件的系统。然后使用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;