User:Andrew Sutherland/MailNews/GlobalDatabase/API/Examples
From MozillaWiki
This page captures API use-cases as they currently exist, and where I want them to get to...
Querying Messages
Finding messages from scratch (now):
// make a new messages query object let query = Gloda.newQuery(Gloda.NOUN_MESSAGE); // messages from my friend that I haven't read... let myFriendHome = Gloda.getIdentityForFullMailAddress("bob@example.com"); query.from(myFriendHome); query.read(false); // synchronous is all we've got for now let messages = query.getAllSync();
Finding messages just in a folder from scratch (now):
// assume we already have an nsIMsgFolder let msgFolder = thatFolderWeAlreadyHave; let query = Gloda.newQuery(Gloda.NOUN_MESSAGE); query.folderURI(msgFolder.URI); let messages = query.getAllSync();
Finding messages related to an existing message (near future):
// assume we already have a message... let message = thatMessageWeAlreadyHave; let query = Gloda.newQuery(Gloda.NOUN_MESSAGE); // find a message sent by the message's author from any of their identities query.from(message.from.contact); // syntax and what not very dubious... query.dateFilter(message.date, "within", "1 month"); let relatedMessages = query.getAllSync();