• Subject: How can I send task request using vCalender/VTodo component using C#
  • Author: Manu
  • Date: 10 May 2011
  • References:
I am writing a separate application to send task requests to the client using simple mail. Then the emails should be added to the mail box task list box in MS Outlook. Here I have used vCalender/vTodo format to set values . But when I send the email it is not sending as a task request and it displays as an email but it is not added to the task list box. That is the question I have. 1. My Outlook version -2007. 2. language - C#.net 3. An Outlook add-in or Outlook automatic application? Not a Add-in. A separate application there should not be a reference to the Outlook. 4. Visual Studio version - VS 2008 This is what I did. public string CreateVTODO(DateTime start, DateTime end, String body, String sub, String status) { //Here I am not using parameters in method body. StringBuilder sbvCalender2 = new StringBuilder(); sbvCalender2.Append("METHOD: REQUEST"); sbvCalender2.Append("\n"); sbvCalender2.Append("BEGIN:VCALENDAR"); sbvCalender2.Append("\n"); sbvCalender2.Append("PRODID:-//ABC Corporation//NONSGML My Product// EN"); sbvCalender2.Append("\n"); sbvCalender2.Append("BEGIN:TODO"); sbvCalender2.Append("\n"); sbvCalender2.Append("20110502T134500Z"); sbvCalender2.Append("\n"); sbvCalender2.Append("SEQUENCE:2"); sbvCalender2.Append("\n"); sbvCalender2.Append("UID:manula.m@eyepax.com"); sbvCalender2.Append("\n"); sbvCalender2.Append("ORGANIZER:MAILTO:derick.k@eye pax.com"); sbvCalender2.Append("\n"); sbvCalender2.Append("ATTENDEE;PARTSTAT=ACCEPTED:MA ILTO:derick.k@eyepax.com"); sbvCalender2.Append("\n"); sbvCalender2.Append("DUE:20110502T134500Z"); sbvCalender2.Append("\n"); sbvCalender2.Append("STATUS:NEEDS-ACTION"); sbvCalender2.Append("\n"); sbvCalender2.Append("SUMMARY:Kolkata Kinght Riders"); sbvCalender2.Append("\n"); sbvCalender2.Append("END:VTODO"); sbvCalender2.Append("\n"); sbvCalender2.Append("END:VCALENDAR"); return sbvCalender2.ToString(); } public void SendmsgVTODO(DateTime start, DateTime end, String body, String sub, String status) { MailMessage mail = new MailMessage(); SmtpClient client = new SmtpClient(); //Set the date and time DateTime startDate = start; DateTime endDate = end; //Location where you want to save the vCalendar file string attachUrl = @"E:\SaveVCalenderFile\Test.vcs"; //Create task using (StreamWriter sw = new StreamWriter(attachUrl)) { sw.Write(CreateVTODO(startDate, endDate, body, sub, status)); } //Attach the task Attachment mailAttachment = new Attachment(attachUrl); mail.Attachments.Add(mailAttachment); MailAddress fromAdd = new MailAddress("sandun.k@eyepax.com"); mail.To.Add("manula.m@eyepax.com"); mail.From = fromAdd; mail.Subject = "Test New Dk"; mail.Body = sbvCalender2.ToString(); mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; client.Host = "smtp.gmail.com"; client.Port = 587; client.UseDefaultCredentials = true; client.Credentials = new NetworkCredential("eyepaxtest@gmail.com", "eyepax563"); client.Send(mail); mailAttachment.Dispose(); } Please help me.
10 May 2011How can I send task request using vCalender/VTodo component using C#.Manu
Contact Us
All times are in (US) Eastern Daylight Time (GMT -4:00)