我想标记所有包含日历邀请的传入邮件。然后我想将它们移动到不同的文件夹中。我尝试了这个答案中描述的方法,但它不起作用:我尝试了一个名为“Content-Type”的标题,内容为“text/calendar”,但没有用。
我还尝试了插件FiltaQuilla,但也失败了。我在那里使用了以下代码:
var sHeaderToLookFor = "content-type";
var sContentInHeader = "text/calendar";
var bFoundIt = false;
function msgHdrGetHeaders(aMsgHdr, k) {
let uri = aMsgHdr.folder.getUriForMsg(aMsgHdr);
let messageService = MailServices.messenger.messageServiceFromURI(uri);
MsgHdrToMimeMessage(aMsgHdr, null, function (aMsgHdr, aMimeMsg) { k(aMimeMsg); }, true, { partsOnDemand: true, examineEncryptedParts:true });
}
msgHdrGetHeaders(message, function (aHeaders) {
if (aHeaders.has(sHeaderToLookFor)) {
var pattern = new RegExp(sContentInHeader);
Application.console.log("InBetween_1");
if (!bFoundIt)
bFoundIt= pattern.test(aHeaders.get(sHeaderToLookFor));
Application.console.log(bFoundIt);
Application.console.log("InBetween_2");
}
});
Application.console.log("AtEnd_1");
Application.console.log(bFoundIt);
Application.console.log("AtEnd_2");
bFoundIt;
Run Code Online (Sandbox Code Playgroud)
在带有 .ics 邀请的电子邮件上测试过滤器后,我在控制台上有以下输出:
AtEnd_1
false
AtEnd_2
InBetween_1
true
InBetween_2
Run Code Online (Sandbox Code Playgroud)
所以基本上,这个带有 …