Opening message in Thunderbird default message window, with message header

Hi,

I need to find a way to open a message in the default Thunderbird
message window. I only have the message header information, but to open
the message window i need the messageUri, folderUri and gDBView:

window.openDialog( "chrome://messenger/content/messageWindow.xul",
"_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
gDBView );

Is there any other way to open the message window, or how can I get
these arguments with just the header information? Trouble is, I'm not in 
the main thunderbird view when calling my function, so also the gDBView 
might be trouble.

I was wondering if there was a way to go around this by implementing 
some kind of method to select the message in question in the TB main 
view, and then open the message window. Then all those value would be 
easy to get.


0
Teemu
4/24/2009 11:58:08 PM
📁 mozilla.dev.extensions
📃 5694 articles.
⭐ 0 followers.

💬 9 Replies
👁️‍🗨️ 1232 Views

Teemu Hautala wrote:
> Hi,
> 
> I need to find a way to open a message in the default Thunderbird
> message window. I only have the message header information, but to open
> the message window i need the messageUri, folderUri and gDBView:
> 
> window.openDialog( "chrome://messenger/content/messageWindow.xul",
> "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
> gDBView );
> 
> Is there any other way to open the message window, or how can I get
> these arguments with just the header information? Trouble is, I'm not in 
> the main thunderbird view when calling my function, so also the gDBView 
> might be trouble.
> 
> I was wondering if there was a way to go around this by implementing 
> some kind of method to select the message in question in the TB main 
> view, and then open the message window. Then all those value would be 
> easy to get.
> 

Actually I also have some trouble getting the message header... 
currently I get some chosen data from the message header and store it 
into a file. I was thinking that I would be able to use just the 
messageId to get the whole header, but now seems that even that isn't so 
easy. I managed to pass the gDBView to my extension window, but haven't 
yet been able to do much with it. At this point I don't know if it's 
even usable (I just passed it as an argument in window.opendialog(..)).

0
Teemu
4/25/2009 12:29:05 AM
 [25.04.2009 02:29]    �Teemu Hautala� wrote:
> Teemu Hautala wrote:
>> Hi,
>>
>> I need to find a way to open a message in the default Thunderbird
>> message window. I only have the message header information, but to open
>> the message window i need the messageUri, folderUri and gDBView:
>>
>> window.openDialog( "chrome://messenger/content/messageWindow.xul",
>> "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
>> gDBView );
>>
>> Is there any other way to open the message window, or how can I get
>> these arguments with just the header information? Trouble is, I'm not 
>> in the main thunderbird view when calling my function, so also the 
>> gDBView might be trouble.
>>
>> I was wondering if there was a way to go around this by implementing 
>> some kind of method to select the message in question in the TB main 
>> view, and then open the message window. Then all those value would be 
>> easy to get.
>>
>
> Actually I also have some trouble getting the message header... 
> currently I get some chosen data from the message header and store it 
> into a file. I was thinking that I would be able to use just the 
> messageId to get the whole header, but now seems that even that isn't 
> so easy. I managed to pass the gDBView to my extension window, but 
> haven't yet been able to do much with it. At this point I don't know 
> if it's even usable (I just passed it as an argument in 
> window.opendialog(..)).
>
Maybe you have a look at ReminderFox. We use some code originally 
developed by Markus Hossner. With ReminderFox we save the messageId with 
a reminder/event and have the possibility to open the message using an 
icon, also TB isn't running (when ReminderFox runs ontop of Firefox).
G�nter
0
gNeandr
4/25/2009 6:45:15 AM
On 04/24/2009 05:29 PM, Teemu Hautala wrote:
> Actually I also have some trouble getting the message header...
> currently I get some chosen data from the message header and store it
> into a file. I was thinking that I would be able to use just the
> messageId to get the whole header, but now seems that even that isn't so
> easy. I managed to pass the gDBView to my extension window, but haven't
> yet been able to do much with it. At this point I don't know if it's
> even usable (I just passed it as an argument in window.opendialog(..)).
>

If you have the message-id and know what folder the message is in, you 
can get the header from the database (which you get from the folder).

Example:
let msgHdr = folder.msgDatabase.getMsgHdrForMessageID(messageId);

where:
folder is an nsIMsgFolder

Andrew
0
Andrew
4/25/2009 6:49:28 AM
On 04/24/2009 04:58 PM, Teemu Hautala wrote:
> Hi,
>
> I need to find a way to open a message in the default Thunderbird
> message window. I only have the message header information, but to open
> the message window i need the messageUri, folderUri and gDBView:
>
> window.openDialog( "chrome://messenger/content/messageWindow.xul",
> "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
> gDBView );
>
> Is there any other way to open the message window, or how can I get
> these arguments with just the header information? Trouble is, I'm not in
> the main thunderbird view when calling my function, so also the gDBView
> might be trouble.
>
> I was wondering if there was a way to go around this by implementing
> some kind of method to select the message in question in the TB main
> view, and then open the message window. Then all those value would be
> easy to get.
>
>

given an nsIMsgDBHdr msgHdr:

let messageUri = msgHdr.folder.getUriForMsg(msgHdr);
let folderUri = msgHdr.folder.URI;

I'm not looking at the code right now, but presumably what the argument 
wants is an nsIMsgDBView that currently has the message visible in it. 
Given a message header, you can get a folder, which you can use to 
instantiate a new db view on the folder.

Andrew
0
Andrew
4/25/2009 6:54:14 AM
Andrew Sutherland wrote:
> On 04/24/2009 04:58 PM, Teemu Hautala wrote:
>> Hi,
>>
>> I need to find a way to open a message in the default Thunderbird
>> message window. I only have the message header information, but to open
>> the message window i need the messageUri, folderUri and gDBView:
>>
>> window.openDialog( "chrome://messenger/content/messageWindow.xul",
>> "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
>> gDBView );
>>
>> Is there any other way to open the message window, or how can I get
>> these arguments with just the header information? Trouble is, I'm not in
>> the main thunderbird view when calling my function, so also the gDBView
>> might be trouble.
>>
>> I was wondering if there was a way to go around this by implementing
>> some kind of method to select the message in question in the TB main
>> view, and then open the message window. Then all those value would be
>> easy to get.
>>
>>
> 
> given an nsIMsgDBHdr msgHdr:
> 
> let messageUri = msgHdr.folder.getUriForMsg(msgHdr);
> let folderUri = msgHdr.folder.URI;
> 
> I'm not looking at the code right now, but presumably what the argument 
> wants is an nsIMsgDBView that currently has the message visible in it. 
> Given a message header, you can get a folder, which you can use to 
> instantiate a new db view on the folder.
> 
> Andrew
> 

Thanks, I'll try these things tonight. Though right now I'm bit
uncertain how to get the URI of the message folder, which I guess I'll
need to get the nsIMsgFolder. There's a method for  getting the URI of a
message through the nsIMsgFolder, but couldn't find  a similar method
for folder. The URI's seem very similar though, so maybe I can do some 
tricks with the strings to get the folder URI.

Also there might be a problem with this, because when I get the
nsIMsgDBHdr, the folder can be changed later by other functionality of
my extension (and by user). I guess I have to somehow figure out of 
updating the folder data I have if this happens, or then find out how I 
could search through all the folders visible for thunderbird, with just 
the messageId at hand.

DB views are still quite unfamiliar for me. Is there any short guide of
how to use them available? Or rather, how to manipulate the thread pane
in Thunderbird through them. I'll try to get my head wrappend around the
docs in MDC, but so far they have been be bit unrevealing.

I'm hoping to have a beta version of my extension out somewhere next
week. Doing it as a one-man project work for my school. Seems this
project became bit bigger than I thought it would.



0
Teemu
4/25/2009 4:05:18 PM
 [25.04.2009 18:05]    �Teemu Hautala� wrote:
> Andrew Sutherland wrote:
>> On 04/24/2009 04:58 PM, Teemu Hautala wrote:
>>> Hi,
>>>
>>> I need to find a way to open a message in the default Thunderbird
>>> message window. I only have the message header information, but to open
>>> the message window i need the messageUri, folderUri and gDBView:
>>>
>>> window.openDialog( "chrome://messenger/content/messageWindow.xul",
>>> "_blank", "all,chrome,dialog=no,status,toolbar", messageUri, folderUri,
>>> gDBView );
>>>
>>> Is there any other way to open the message window, or how can I get
>>> these arguments with just the header information? Trouble is, I'm 
>>> not in
>>> the main thunderbird view when calling my function, so also the gDBView
>>> might be trouble.
>>>
>>> I was wondering if there was a way to go around this by implementing
>>> some kind of method to select the message in question in the TB main
>>> view, and then open the message window. Then all those value would be
>>> easy to get.
>>>
>>>
>>
>> given an nsIMsgDBHdr msgHdr:
>>
>> let messageUri = msgHdr.folder.getUriForMsg(msgHdr);
>> let folderUri = msgHdr.folder.URI;
>>
>> I'm not looking at the code right now, but presumably what the 
>> argument wants is an nsIMsgDBView that currently has the message 
>> visible in it. Given a message header, you can get a folder, which 
>> you can use to instantiate a new db view on the folder.
>>
>> Andrew
>>
>
> Thanks, I'll try these things tonight. Though right now I'm bit
> uncertain how to get the URI of the message folder, which I guess I'll
> need to get the nsIMsgFolder. There's a method for  getting the URI of a
> message through the nsIMsgFolder, but couldn't find  a similar method
> for folder. The URI's seem very similar though, so maybe I can do some 
> tricks with the strings to get the folder URI.
>
> Also there might be a problem with this, because when I get the
> nsIMsgDBHdr, the folder can be changed later by other functionality of
> my extension (and by user). I guess I have to somehow figure out of 
> updating the folder data I have if this happens, or then find out how 
> I could search through all the folders visible for thunderbird, with 
> just the messageId at hand.
>
> DB views are still quite unfamiliar for me. Is there any short guide of
> how to use them available? Or rather, how to manipulate the thread pane
> in Thunderbird through them. I'll try to get my head wrappend around the
> docs in MDC, but so far they have been be bit unrevealing.
>
> I'm hoping to have a beta version of my extension out somewhere next
> week. Doing it as a one-man project work for my school. Seems this
> project became bit bigger than I thought it would.
>
>
>
Just to motivate you to look into ReminderFox for the use of 
'messageID'. We have had similar situation/problems and we find the 
message also the message is moved along the folders. Markus did a great 
job with his code!!
Dont hesitate to call back if you need details or directions ...
0
gNeandr
4/25/2009 5:47:24 PM
gNeandr wrote:


>>
> Just to motivate you to look into ReminderFox for the use of 
> 'messageID'. We have had similar situation/problems and we find the 
> message also the message is moved along the folders. Markus did a great 
> job with his code!!
> Dont hesitate to call back if you need details or directions ...
> 

Thanks! Seems that there is lot of things in ReminderFox which can help 
me. The way to get all the folder URI's to search seems quite 
complicated though... trying to understand how it all works. Though I 
guess trying to update my database on folder listeners events wouldn't 
really work anyway, if the user makes changes somewhere else.

0
Teemu
4/25/2009 6:50:13 PM
Teemu Hautala wrote:
> gNeandr wrote:
> 
> 
>>>
>> Just to motivate you to look into ReminderFox for the use of 
>> 'messageID'. We have had similar situation/problems and we find the 
>> message also the message is moved along the folders. Markus did a 
>> great job with his code!!
>> Dont hesitate to call back if you need details or directions ...
>>
> 
> Thanks! Seems that there is lot of things in ReminderFox which can help 
> me. The way to get all the folder URI's to search seems quite 
> complicated though... trying to understand how it all works. Though I 
> guess trying to update my database on folder listeners events wouldn't 
> really work anyway, if the user makes changes somewhere else.
> 
> 

Got my extension to work in the same way as ReminderFox, by searching
with the messageId. That's quite a bit of code for something that I
thought would be pretty simple. Thanks a lot, I couldn't have done that
by myself in the time I have left to finish this project.

Now however I have another issue... I would need to get the Inbox of
each of the accounts, separated from the other folders. I've managed to 
parse the main folders in each account, but now I'm wondering, is Inbox 
always named as "Inbox" in TB? For now, I will assume it is and carry on.

I need to trust this item also because I have a folder listener, which I 
want to limit only to Inbox and Sent folders of each account. It's bit 
strange though, because I've noticed on my testing that sometimes I get 
a duplicate event in "INBOX", in addition to "Inbox" event.

But thanks for the help, right now I'm going forward again.

0
Teemu
4/26/2009 8:10:15 PM
Teemu Hautala wrote:

> I would need to get the Inbox of each of the accounts, separated from 
> the other folders.

That's easy in TB3, just call getFolderWithFlag(nsMsgFolderFlags.Inbox); 
on each account's root folder.

-- 
Warning: May contain traces of nuts.
0
Neil
4/27/2009 11:22:31 AM
Reply: