get header from messageID

I need to get a message from a messageID (or gloda.headerMessageId).

I see that I can get it from the DB: getMsgHdrForMessageID().

I can get the DB from a folder by getMsgDatabase(in nsIMsgWindow msgWindow);

What do I use for msgWindow? I thought there is only one DB, and I could do something like: 

gFolderDisplay.displayedFolder.getMsgDatabase( ????).getMsgHdrForMessageID(myID);

any help is appreciated,

Klaus
0
opto
3/19/2017 7:29:59 PM
mozilla.dev.apps.thunderbird 3312 articles. 0 followers. Post Follow

3 Replies
88 Views

Similar Articles

[PageSpeed] 42

Dne ned=C4=9Ble 19. b=C5=99ezna 2017 20:30:00 UTC+1 opto napsal(a):
> I need to get a message from a messageID (or gloda.headerMessageId).
>=20
> I see that I can get it from the DB: getMsgHdrForMessageID().
>=20
> I can get the DB from a folder by getMsgDatabase(in nsIMsgWindow msgWindo=
w);
>=20
> What do I use for msgWindow? I thought there is only one DB, and I could =
do something like:=20
>=20
> gFolderDisplay.displayedFolder.getMsgDatabase( ????).getMsgHdrForMessageI=
D(myID);
>=20
> any help is appreciated,
>=20
> Klaus

nsIMsgFolder has msgDatabase atribute. You don't need to worry about msgWin=
dow.

  /**
   * Gets the message database for the folder.
   *
   * Note that if the database is out of date, the implementation MAY choos=
e to
   * throw an error. For a handle to the database which MAY NOT throw an er=
ror,
   * one can use getDBFolderInfoAndDB.
   *
   * The attribute can also be set to another database or to null to force =
the
   * folder to reopen the same database when it is needed again.
   *
   * @exception NS_MSG_ERROR_FOLDER_SUMMARY_MISSING If the database does no=
t
   *                         exist.
   * @exception NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE If the database con=
tains
   *                         out of date information.
   * @see nsIMsgFolder::getDBFolderInfoAndDB.
   */
attribute nsIMsgDatabase msgDatabase;

Hope thats what you looking for.
0
karel
3/19/2017 9:31:06 PM
many thanks!!

I am just thinking: what happens if there are several headers with the same messageID?

Like if I copy the email to another folder, I have two messages with same messageid. But I should have two headers, because msgHdr.folder.name would be different for the two versions of the message.

many thanks,

Klaus
0
opto
3/19/2017 10:02:28 PM
Dne ned=C4=9Ble 19. b=C5=99ezna 2017 23:02:29 UTC+1 opto napsal(a):
> many thanks!!
>=20
> I am just thinking: what happens if there are several headers with the sa=
me messageID?
>=20
> Like if I copy the email to another folder, I have two messages with same=
 messageid. But I should have two headers, because msgHdr.folder.name would=
 be different for the two versions of the message.
>=20
> many thanks,
>=20
> Klaus

Well you will have the original msgDBHdr in folder1 and the second msgDBHdr=
 will be in folder2 both with the same messageId. Every folder has its own =
database of msgDBHdrs. Nothing special about this. If there were two messag=
es with the same ID in one folder then getMessageById would return the firs=
t occurance I suppose.
0
karel
3/19/2017 10:27:27 PM
Reply: