I have Following code for sending an appointment through Email in C#.
What happens is that when i open this file from email,the outlook will display it in a massage tab.
Now if i want to open it as a task in outlook,what should i do?
public string MakeHourEvent(string subject, string location,
DateTime date, string startTime, string endTime)
{
string filePath = string.Empty;
string path = HttpContext.Current.Server.MapPath(@"\iCal\");
filePath = path + subject + ".ics";
writer = new StreamWriter(filePath);
writer.WriteLine("BEGIN:VCALENDAR");
writer.WriteLine("VERSION:2.0");
writer.WriteLine("PRODID:-//hacksw/handcal//NONSGML v1.0//EN");
writer.WriteLine("BEGIN:VEVENT");
string startDateTime = GetFormatedDate(date)+"T"+GetFormattedTime(startTime);
string endDateTime = GetFormatedDate(date) + "T" + GetFormattedTime(endTime);
writer.WriteLine("DTSTART:" + startDateTime);
writer.WriteLine("DTEND:" + endDateTime);
writer.WriteLine("SUMMARY:" + subject);
writer.WriteLine("LOCATION:" + location);
writer.WriteLine("END:VEVENT");
writer.WriteLine("END:VCALENDAR");
writer.Close();
return filePath;
}
public void SendMail(string from, string to,
string subject, string body, Attachment attachment)
{
MailMessage mail = new MailMessage(from, to, subject, body);
mail.Attachments.Add(attachment);
SmtpClient smtp = new SmtpClient("localhost");
smtp.Send(mail);
mail.Dispose();
}