Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am trying to send .ics file as an attachment to user by creating ics file and email from C# code it self.I am able to send ICS file saving in to a local drive and attaching to email. I need start time and end time 24 hours format.


I created .ics file like this

String[] contents = { "BEGIN:VCALENDAR",
"PRODID:-//Flo Inc.//FloSoft//EN",
"BEGIN:VEVENT",
"DTSTART:" +DateTime.Now,
"DTEND:" + DateTime.Now,
"LOCATION:" + schLocation,
"DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + emailContentVM.CalendarBody,
"SUMMARY:" + strSubjectText, "PRIORITY:3",
"END:VEVENT", "END:VCALENDAR" };


System.IO.File.WriteAllLines(System.Web.HttpContext.Current.Server.MapPath(@"~\Content\Images\CrewHub\TASAuth.ics"), contents);
emailContentVM.FileName = "TASAuth.ics";
emailContentVM.ContentType = " text/calendar; charset=utf-8";
string strContent = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@"~\Content\Images\CrewHub\TASAuth.ics"));
emailContentVM.Content = strContent;

string strEmailResponce = SendEmailWithCalendarAttachement(emailContentVM);
return strEmailResponce;


using above code am getting
start time : Tue 1/27/ 2015 5:30 Pm
End time: Tue 1/27/2015 6:30 pm

I need out put like this
VB
start time : Tue 1/27/ 2015  5:30
End time: Tue 1/27/2015 6:30


i need time 24 hours format , plz kindly help me.

Thanks,
Ram
Posted
Updated 27-Jan-15 1:13am
v2

 
Share this answer
 
For your special requirement you can do like this:
CultureInfo ci = new CultureInfo("en-US");
string dateTimeString = DateTime.Now.ToString("ddd d/M/yyyy h:mm", ci);
 
Share this answer
 

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