Thunderbird:Extension Snippets

From MozillaWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This page is for javascript code snippets of things I've figured out how to do in Thunderbird. It is posted to the mozilla wiki in the hopes of being useful to others.

Create a Todo

(Note:this snippet requires the lightning extension to work)

The following snippet is how you create a new todo item and add it to the the first calendar on your list. You could instead smartly iterate over the cals to get the right one that you wanted.

var todo = Components.classes["@mozilla.org/calendar/todo;1"].
    createInstance(Components.interfaces.calITodo);
var date = Components.classes["@mozilla.org/calendar/datetime;1"].
    createInstance(Components.interfaces.calIDateTime);
date.icalString = "20080907T120000Z";

todo.title = "Crazy new todo";
todo.dueDate = date;

var calManager = Components.classes["@mozilla.org/calendar/manager;1"].
    getService(Components.interfaces.calICalendarManager);

var cals = calManager.getCalendars({});
var cal = cals[0]; // gets the first callendar

cal.addItem(todo, null);