Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?


C#
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;
   }




C#
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();
   }
Posted
Updated 10-Sep-14 23:43pm
v2

1 solution

For open task in microsoft outlook

System.Diagnostics.Process.Start("mailto:Tomail?subject=subject_name Messege &body="+MsgBody);


Tomail->To Mail Address

subject_name ->Subject Should display in outlook subject box

MsgBody->Body of the mail which want send
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900