我有一个电子邮件ID列表。我想过滤收件箱消息,只显示雷鸟中那些用户的电子邮件。请帮我这样做。

这是我到目前为止尝试过的方法,它不起作用。但是我收到了完全不相关的错误消息“我们无法打印或预览此页面”。

var gLocalIncomingServer = MailServices.accounts.localFoldersServer;
var gLocalMsgAccount = MailServices.accounts.FindAccountForServer(
 gLocalIncomingServer);

var gLocalRootFolder = gLocalIncomingServer.rootMsgFolder
                  .QueryInterface(Ci.nsIMsgLocalMailFolder);

const kInboxFlag = Components.interfaces.nsMsgFolderFlags.Inbox;
var gLocalInboxFolder = gLocalRootFolder.getFolderWithFlags(kInboxFlag);
gLocalRootFolder.findSubFolder(gLocalInboxFolder.URI);

gLocalInboxFolder.setFlag(Ci.nsMsgFolderFlags.Mail);

 // Force an initialization of the Inbox folder database.
 var folderName = gLocalInboxFolder.prettiestName;

 var aValue = "[email protected]";
 var aAttrib = Ci.nsMsgSearchAttrib.Sender;
 var aop = nsMsgSearchOp.Contains;;
 var hitCount = 1;

var searchListener =
 {
  onSearchHit: function(dbHdr, folder) { hitCount++; },
  onSearchDone: function(status)
  {
    print("Finished search does " + aHitCount + " equal " + hitCount + "?");
    searchSession = null;
    do_check_eq(aHitCount, hitCount);
    if (onDone)
    onDone();
  },
 onNewSearch: function() {hitCount = 0;}
};

// define and initiate the search session

var hitCount;
var searchSession = Cc["@mozilla.org/messenger/searchSession;1"]
                    .createInstance(Ci.nsIMsgSearchSession);
searchSession.addScopeTerm(Ci.nsMsgSearchScope.offlineMail, gLocalInboxFolder);
var searchTerm = searchSession.createTerm();
searchTerm.attrib = aAttrib;

var value = searchTerm.value;
// This is tricky - value.attrib must be set before actual values
value.attrib = aAttrib;
value.str = aValue;
searchTerm.value = value;
if (aAttrib > nsMsgSearchAttrib.OtherHeader)
  searchTerm.arbitraryHeader = gArrayHdrs[aAttrib - 1 - nsMsgSearchAttrib.OtherHeader];
searchTerm.op = aOp;
searchTerm.booleanAnd = false;
searchSession.appendTerm(searchTerm);
searchSession.registerListener(searchListener);
searchSession.search(null);
alert("search is done:");

最佳答案

您看过这个Mozilla页面吗? How do I search for a particular contact property (name, email)?

10-05 20:08