Estoy intentando enviar un correo electrónico con un calendario ics como adjunto, logro que lo envié, sin embargo en la hora no logro que envié los parámetros de inicio y fin. Me está enviando la reunión entre el rango de la hora actual.
Este es el código
public void SendMail(string tomailid)
{
try
{
string Body = "Cuerpo del Correo";
//Attach Calender
string schLocation = "Conference Room";
string schSubject = "Seguimiento de Importaciones";
string schDescription = "SGC - Seguimiento Orden de Compra";
System.DateTime schBeginDate = Convert.ToDateTime(txtfechaseguimiento.Text);
System.DateTime schEndDate = schBeginDate.AddMinutes(30);
//PUTTING THE MEETING DETAILS INTO AN ARRAY OF STRING
String[] contents = { "BEGIN:VCALENDAR",
"PRODID:-//Flo Inc.//FloSoft//EN",
"BEGIN:VEVENT",
"DTSTART:" + schBeginDate.ToUniversalTime().ToString("ddMMyyyy\\THHmmss\\Z"),
"DTEND:" + schEndDate.ToUniversalTime().ToString("ddMMyyyy\\THHmmss\\Z"),
"LOCATION:" + schLocation,
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + schDescription,
"SUMMARY:" + schSubject, "PRIORITY:3",
"END:VEVENT", "END:VCALENDAR" };
/*THE METHOD 'WriteAllLines' CREATES A FILE IN THE SPECIFIED PATH WITH
THE SPECIFIED NAME,WRITES THE ARRAY OF CONTENTS INTO THE FILE AND CLOSES THE
FILE.SUPPOSE THE FILE ALREADY EXISTS IN THE SPECIFIED LOCATION,THE CONTENTS
IN THE FILE ARE OVERWRITTEN*/
System.IO.File.WriteAllLines(Server.MapPath("Sample.ics"), contents);
//string name = Session["UserName"].ToString();
MailMessage myMailMessage = new MailMessage();
myMailMessage.To.Add(tomailid);
myMailMessage.From = new MailAddress("[email protected]");
myMailMessage.Subject = "You have 1 scheduled Meeting";
Attachment mailAttachment = new Attachment(Server.MapPath("Sample.ics"));
myMailMessage.Attachments.Add(mailAttachment);
myMailMessage.Body = Body;
mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySmtpClient.Host = "smtp.office365.com";
mySmtpClient.Port = 587;
mySmtpClient.EnableSsl = true;
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = new NetworkCredential("[email protected]", "password", "[email protected]");
//mySmtpClient.TargetName = "STARTTLS/smtp.office365.com";
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
mySmtpClient.Send(myMailMessage);
}
catch (Exception ex)
{
}
}
Random rnd = new Random();
copia lo que hay encontents
edita la pregunta y le agregas ese dato :D