VS.NET 2010/2012 Users Click Here   

HOMECONTACT PRODUCTS DOWNLOADS PURCHASE TESTIMONIALS FORUMS COMPANY CONTACT
Home
Products
Downloads
Purchase
Licensing
Licensing FAQ
Software Updates
Support Forums
Testimonials
Feature Requests
Guarantee
About Us
Contact Us
Hosting Companies
Privacy Policy
   
Shopping Cart


Search

All Day Events in an iCalendar

by Dave 1. October 2010 09:06

By default, the RFC standard for the iCalendar specification does not support all day events.

However, both Outlook and Lotus Notes support this capability. Both do it a bit differently.

Below is a code example of how to use the iCalendar functionality of aspNetEmail to create all day events in both Lotus Notes and Outlook. 

static void AllDayEvent()
{
	//create the email message object
	EmailMessage m = new EmailMessage( "192.168.1.106" );
	m.From = "me@example.com";
	m.To = "you@blah.com";
	
	//create an all day event for next week
	DateTime eventDay = DateTime.Now.AddDays(7);

	m.Subject = "all day event for " + eventDay.ToShortDateString();

	//uncomment to create an iCal for Lotus Notes
	//iCalendar iCal= AllDayEventForLotus( eventDay );

	//create an iCal for Outlook
	iCalendar iCal = AllDayEventForOutlook( eventDay );

	//set some event properties
	//set the properties
	iCal.Event.Summary.Text = "Sales Meeting"; 
	iCal.Event.Location.Text = "100 main conf room"; 


	//when we add it to the EmailMessage object, all EmailMessage recipients will
	//be added to the iCalendar *if* the iCalendar does not have any recipients
	//if we wanted to add additional attendees we could use
	//ic.Event.Attendees.Add( ... )
	m.AddCalendar(iCal); 

	m.Logging = true;
	m.LogPath = "c:\\email.log";
	m.LogOverwrite = true;

	m.SaveToFile( "c:\\temp\\" );
	m.Send();


}
static iCalendar AllDayEventForLotus(DateTime eventDay)
{
	iCalendar iCal = new iCalendar(); 

	DateTime start = new DateTime( eventDay.Year, eventDay.Year, eventDay.Day, 4, 0, 0 );
	DateTime end = new DateTime( eventDay.Year, eventDay.Year, eventDay.Day, 20, 0, 0 );

	iCal.Event.DateStart.Date = start;
	iCal.Event.DateEnd.Date = end;
	iCal.Event.Priority.PriorityType = PriorityType.Normal; 

	return iCal;
}

static iCalendar AllDayEventForOutlook( DateTime eventDay)
{
	DateTime dayStart = eventDay;
	DateTime dayEnd = eventDay.AddDays( 1 );

	iCalendar iCal = new iCalendar(); 

	iCal.TimeZone.Format = TimeZoneFormat.SuppressTimeZoneRules;

	iCal.Event.DateStart.AddParameter( "VALUE", "DATE:" + dayStart.ToString("yyyyMMdd")  );
	iCal.Event.DateEnd.AddParameter( "VALUE", "DATE:" + dayEnd.ToString( "yyyyMMdd" ) );
	iCal.Event.TimeTransparency.TransparencyType = TransparencyType.Transparent; 

	iCal.Event.Priority.PriorityType = PriorityType.Normal; 

	//set various Outlook X-Headers, so Outlook will recognize it as an All Day Event.
	iCal.Event.Properties.Add( new CustomCalendarProperty( "X-MICROSOFT-CDO-BUSYSTATUS", "FREE" ) );
	iCal.Event.Properties.Add( new CustomCalendarProperty( "X-MICROSOFT-CDO-INSTTYPE", "0" ) );
	iCal.Event.Properties.Add( new CustomCalendarProperty( "X-MICROSOFT-CDO-INTENDEDSTATUS", "FREE" ) );
	iCal.Event.Properties.Add( new CustomCalendarProperty( "X-MICROSOFT-CDO-ALLDAYEVENT", "TRUE" ) );

	return iCal;
}



 

 

Testimonial

Thanks for the help and the great products. "

J. Latimer

Read more testimonials
ListNanny aspNetDNS aspNetEmail aspNetPOP3 aspNetMX IPMuncher aspNetMIME aspNetPING aspNetTraceRoute aspNetIMAP aspNetMHT