rem: var dateFormat = new DateFormater(); 
context: function sendEvent(){  var CalendarDataFilePath;  var nsIMsgCompFieldsComponent;  var nsIMsgCompFields;  var nsIMsgComposeParamsComponent;  var nsIMsgComposeParams;  var nsIMsgComposeServiceComponent;  var nsIMsgComposeService;  var nsIMsgCompFormat;  var nsIMsgCompType;  var nsIMsgAttachmentComponent;  var nsIMsgAttachment;  CalendarDataFilePath = getCalendarDataFilePath();  if (! CalendarDataFilePath) {    alert( "No calendarDataFilePath in calendarMail.js" );    return;  }  /* Outputs plain text for message body like   *   *   Summary: Pre-midnight gathering   *   When: Friday, 31 December 1999 11:00 PM -- 11:45 PM   *   Where: City hall   *   Organizer: Moz <moz@mozilla.org>   *   *   We will gather and ride over en-masse.   *    * For recurring event, date is next occurrence (or prev if none).   * Date is not repeated if end is same.  Time is omitted for all day events.   */  var CalendarText = "";  var EmailBody = "";  var Separator = "";  for( var i = 0; i < gCalendarWindow.EventSelection.selectedEvents.length; i++ ) {    var event = gCalendarWindow.EventSelection.selectedEvents[i].clone();    if( event ) {      event.alarm = false;      if( event.method == 0 )	event.method = event.ICAL_METHOD_PUBLISH;      CalendarText += event.getIcalString();      var dateFormat = new DateFormater();      var eventDuration  = event.end.getTime() - event.start.getTime();      var displayStartDate = getNextOrPreviousOccurrence(event);      var displayEndDate   = new Date(displayStartDate.getTime() + eventDuration);      if (event.allDay)	displayEndDate.setDate(displayEndDate.getDate() - 1);      var sameDay = (displayStartDate.getFullYear() == displayEndDate.getFullYear() &&		     displayStartDate.getMonth() == displayEndDate.getMonth() &&		     displayStartDate.getDay() == displayEndDate.getDay());      var sameTime = (displayStartDate.getHours() == displayEndDate.getHours() &&		      displayStartDate.getMinutes() == displayEndDate.getMinutes());      var when = (event.allDay		  ? (sameDay		     // just one day		     ? dateFormat.getFormatedDate(displayStartDate)		     // range of days		     : makeRange(dateFormat.getFormatedDate(displayStartDate),				 dateFormat.getFormatedDate(displayEndDate)))		  : (sameDay		     ? (sameTime			// just one date time			? (dateFormat.getFormatedDate(displayStartDate) +			   " "+ dateFormat.getFormatedTime(displayStartDate))			// range of times on same day			: (dateFormat.getFormatedDate(displayStartDate)+			   " " + makeRange(dateFormat.getFormatedTime(displayStartDate),					   dateFormat.getFormatedTime(displayEndDate))))		     // range across different days		     : makeRange(dateFormat.getFormatedDate(displayStartDate) +				 " "+ dateFormat.getFormatedTime(displayStartDate),				 dateFormat.getFormatedDate(displayEndDate) +				 " "+ dateFormat.getFormatedTime(displayEndDate))));      EmailBody += Separator;      Separator = "\n\n";      EmailBody += (emailStringBundle.GetStringFromName( "Summary" )+" " + nullToEmpty(event.title) +"\n"+		    emailStringBundle.GetStringFromName( "When" )+" " + when + "\n"+		    emailStringBundle.GetStringFromName( "Where" )+" " + nullToEmpty(event.location) + "\n"+		    emailStringBundle.GetStringFromName( "Organizer" )+" " + gMailIdentity.fullName + " <" + gMailIdentity.email + ">" + "\n" +		    "\n" +		    (event.description == null? "" : event.description + "\n"));    }  }     var EmailSubject;  if( gCalendarWindow.EventSelection.selectedEvents.length == 1 )    EmailSubject = gCalendarWindow.EventSelection.selectedEvents[0].title;  else    EmailSubject = emailStringBundle.GetStringFromName( "EmailSubject" );  saveCalendarObject(CalendarDataFilePath, CalendarText);  // lets open a composer with fields and body prefilled  try {    nsIMsgAttachmentComponent = Components.classes["@mozilla.org/messengercompose/attachment;1"];    nsIMsgAttachment = nsIMsgAttachmentComponent.createInstance(Components.interfaces.nsIMsgAttachment);    nsIMsgAttachment.name = emailStringBundle.GetStringFromName( "AttachmentName" );    nsIMsgAttachment.contentType = "text/calendar";    nsIMsgAttachment.temporary = true;    nsIMsgAttachment.url = "file://" + CalendarDataFilePath;    // lets setup the fields for the message    nsIMsgCompFieldsComponent = Components.classes["@mozilla.org/messengercompose/composefields;1"];    nsIMsgCompFields = nsIMsgCompFieldsComponent.createInstance(Components.interfaces.nsIMsgCompFields);    nsIMsgCompFields.useMultipartAlternative = true;    nsIMsgCompFields.attachVCard = true;    nsIMsgCompFields.from = gMailIdentity.email;    nsIMsgCompFields.replyTo = gMailIdentity.replyTo;    nsIMsgCompFields.subject = EmailSubject;    nsIMsgCompFields.organization = gMailIdentity.organization;    nsIMsgCompFields.body = EmailBody;    nsIMsgCompFields.addAttachment(nsIMsgAttachment);    /* later on we may be able to add:     * returnReceipt, attachVCard     */    // time to handle the message paramaters    nsIMsgComposeParamsComponent = Components.classes["@mozilla.org/messengercompose/composeparams;1"];    nsIMsgComposeParams = nsIMsgComposeParamsComponent.createInstance(Components.interfaces.nsIMsgComposeParams);    nsIMsgComposeParams.composeFields = nsIMsgCompFields;    nsIMsgCompFormat = Components.interfaces.nsIMsgCompFormat;    nsIMsgCompType = Components.interfaces.nsIMsgCompType;    nsIMsgComposeParams.format = nsIMsgCompFormat.PlainText; // this could be a pref for the user    nsIMsgComposeParams.type = nsIMsgCompType.New;    // finally lets pop open a composer window after all this work :)    nsIMsgComposeServiceComponent = Components.classes["@mozilla.org/messengercompose;1"];    nsIMsgComposeService = nsIMsgComposeServiceComponent.getService().QueryInterface(Components.interfaces.nsIMsgComposeService);    nsIMsgComposeService.OpenComposeWindowWithParams(null, nsIMsgComposeParams);  } catch(ex) {    alert( ex );    mdebug("failed to get composer window\nex: " + ex);  }}
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/2d1d3abba69d52d5e91ba3747e24e765007a2cd9/calendarMail.js/clean/calendar/resources/content/calendarMail.js