Objects that implements nsIMsgMessageService
give the user top level routines related to messages like copying, displaying, attachment's manipulation, printing, streaming the message content to eml
format string, etc.
Inherits from: nsISupports
void CopyMessage(in string aSrcURI, in |
[noscript] void CopyMessages(in |
void DisplayMessage(in string aMessageURI, in |
void openAttachment(in string aContentType, in string aFileName, in string aUrl, in string aMessageUri, in |
void SaveMessageToDisk(in string aMessageURI, in |
void GetUrlForUri(in string aMessageURI, out |
void DisplayMessageForPrinting(in string aMessageURI, in |
void Search(in |
|
in string aMessageURI, in in |
boolean isMsgInMemCache(in , in
|
|
Pass in the URI for the message you want to have copied. aCopyListener
already knows about the destination folder.
void CopyMessage(in string aSrcURI, innsIStreamListener
aCopyListener, in boolean aMoveMessage, innsIUrlListener
aUrlListener, innsIMsgWindow
aMsgWindow, out nsIURI aURL);
aSrcURI
url
of the message to copy.aCopyListener
nsIStreamListener
to be notified of copy events.aMoveMessage
true
if you want the message to be moved. false
leaves it as just a copy.aUrlListener
nsIUrlListener
to be notified of url events.aMsgWindow
nsIMsgWindow
for progress and status feedbackaURL
nsIURI
of the message.Copy multiple messages at a time. See CopyMessage
[noscript] void CopyMessages(innsMsgKeyArrayPtr
keys, innsIMsgFolder
srcFolder, innsIStreamListener
aCopyListener, in boolean aMoveMessage, innsIUrlListener
aUrlListener, innsIMsgWindow
aMsgWindow, out nsIURI aURL);
keys
srcFolder
aCopyListener
nsIStreamListener
to be notified of copy events.aMoveMessage
true
if you want the message to be moved. false
leaves it as just a copy.aUrlListener
nsIUrlListener
aMsgWindow
nsIMsgWindow
for progress and status feedbackaURL
nsIURI
of the message. (?)When you want a message displayed....
void DisplayMessage(in string aMessageURI, innsISupports
aDisplayConsumer, innsIMsgWindow
aMsgWindow, innsIUrlListener
aUrlListener, in string aCharsetOverride, outnsIURI
aURL);
aMessageURI
aDisplayConsumer
nsIDocShell
which the message is loaded into.aMsgWindow
nsIMsgWindow
for progress and status feedbackaUrlListener
nsIUrlListener
aCharsetOverride
aURL
nsIURI
of the message.Downloads and opens an attachment.
void openAttachment(in string aContentType, in string aFileName, in string aUrl, in string aMessageUri, innsISupports
aDisplayConsumer, innsIMsgWindow
aMsgWindow, innsIUrlListener
aUrlListener);
aContentType
aFileName
aUrl
aMessageUri
aDisplayConsumer
MsgWindow
nsIMsgWindow
for progress and status feedbackaUrlListener
nsIUrlListener
.When you want to spool a message out to a file on disk. This is an async operation of course.
void SaveMessageToDisk(in string aMessageURI, innsIFileSpec
aFile, in boolean aGenerateDummyEnvelope, innsIUrlListener
aUrlListener, out nsIURI aURL, in boolean canonicalLineEnding, innsIMsgWindow
aMsgWindow);
aMessageURI
aFile
aGenerateDummyEnvelope
false
. Set to true
if you want the message appended at the end of the file.aUrlListener
nsIUrlListener
for being notified when the copy is finished.canonicalLineEnding
aMsgWindow
nsIMsgWindow
for progress and status feedbackaURL
nsIURI
of the saved message.When you have a uri and you would like to convert that to a url which can be run through necko, you can use this method.
void GetUrlForUri(in string aMessageURI, outnsIURI
aURL, innsIMsgWindow
aMsgWindow);
aMessageURI
aMsgWindow
nsIMsgWindow
for progress and status feedbackaURL
nsIURI
of the message.When you want a message displayed in a format that is suitable for printing.
void DisplayMessageForPrinting(in string aMessageURI, innsISupports
aDisplayConsumer, innsIMsgWindow
aMsgWindow, innsIUrlListener
aUrlListener, out nsIURI aURL);
aMessageURI
aDisplayConsumer
nsIDocShell
which the message is loaded into.aMsgWindow
nsIMsgWindow
for progress and status feedbackaUrlListener
aURL
nsIURI
of the message.void Search(innsIMsgSearchSession
aSearchSession, innsIMsgWindow
aMsgWindow, innsIMsgFolder
aMsgFolder, in string aSearchUri);
aSearchSession
nsIMsgSearchSession
to use.aMsgWindow
nsIMsgWindow
for progress and status feedbackaMsgFolder
nsIMsgFolder
aSearchUri
This method streams a message to the passed in consumer. It will also tack aAdditionalHeader
onto the url (e.g., header=filter
). The good thing about this method is that you can extract a standard representation of any message, no matter if they are emails, RSS, news, blogs, etc.
nsIURI streamMessage(in string aMessageURI, innsISupports
aConsumer, innsIMsgWindow
aMsgWindow, innsIUrlListener
aUrlListener, in boolean aConvertData, in string aAdditionalHeader);
aMessageURI
aConsumer
onDataAvailable
method, you can write out the stream data to a local file or concatenate it to a string.aMsgWindow
nsIMsgWindow
for progress and status feedback.aUrlListener
nsIUrlListener
that is notified when url starts and stops.aConvertData
aConvertData
is true, it will create a stream converter from message rfc2822 to */*.aAdditionalHeader
header=filter
The nsIURI
that gets run
For example, the next piece of code shows the selected message code on a dialog: (taken from Mozillazine)
var content = ""; var MessageURI = GetFirstSelectedMessage(); var MsgService = messenger.messageServiceFromURI(MessageURI); var MsgStream = Components.classes["@mozilla.org/network/sync-stream-listener;1"].createInstance(); var consumer = MsgStream.QueryInterface(Components.interfaces.nsIInputStream); var ScriptInput = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(); var ScriptInputStream = ScriptInput.QueryInterface(Components.interfaces.nsIScriptableInputStream); ScriptInputStream.init(consumer); try { MsgService.streamMessage(MessageURI, MsgStream, msgWindow, null, false, null); } catch (ex) { alert("error: "+ex) } ScriptInputStream .available(); while (ScriptInputStream .available()) { content = content + ScriptInputStream .read(512); } alert(content
This method streams a message's headers to the passed in consumer. This is for consumers who want a particular header but don't want to stream the whole message.
nsIURI streamMessage(in string aMessageURI, innsIStreamListener
aConsumer, innsIUrlListener
aUrlListener, in boolean aLocalOnly);
aMessageURI
aConsumer
nsIStreamListener
Generally, a stream listener listening to the message headers. The consumer has to be a stream listener and in your listener's onDataAvailable
method, you can write out the stream data to a local file or concatenate it to a string.aUrlListener
nsIUrlListener
that is notified when url starts and stops, if we run a url.aLocalOnly
If we're offline, then even if aLocalOnly is false, we won't stream over the network
The URL that gets run, if any
Determines whether a message is in the memory cache. Local folders don't implement this.
boolean isMsgInMemCache(innsIURI
aUrl, innsIMsgFolder
aFolder, outnsICacheEntryDescriptor
aCacheEntry);
aUrl
aFolder
aCacheEntry
TRUE if the message is in mem cache; FALSE if it is not.
Go from message uri to nsIMsgDBHdr
:
nsIMsgDBHdr
messageURIToMsgHdr(in string uri);
uri
The URL that gets run, if any.