我正在开发一个gmail上下文小工具来获取发件人电子邮件的名称和电子邮件,但我有问题要获取发件人的姓名。我尝试了不同的方式:
它似乎已过时,我无法在“Google Apps Marketplace SDK”上找到我可以使用自定义提取程序上传manifest.xml的位置。任何想法!! ??
2. Using pre-canned extractors
我定义了google.com:SenderEmailExtractor并选择“邮件发件人地址和邮件发件人名称”范围。不可否认,我只是在google.contentmatch.getContentMatches()中收到发件人的电子邮件,但没有任何与发件人姓名相关的内容!我错过了什么?
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="DEV"
description="Gmail Gadget v2.0"
height="50"
author=""
author_email=""
author_location="Canada">
<!-- This one is not specific to Gmail contextual gadgets. -->
<Require feature="dynamic-height"/>
<Require feature="views" />
<Require feature="google.contentmatch">
<Param name="extractors">
google.com:MessageIDExtractor
</Param>
<Param name="extractors">
google.com:SenderEmailExtractor
</Param>
<Param name="extractors">
google.com:RawSubjectExtractor
</Param>
<Param name="extractors">
google.com:EmailTimeExtractor
</Param>
<Param name="extractors">
google.com:EmailAddressExtractor
</Param>
<Param name="extractors">
google.com:RecipientEmailExtractor
</Param>
<Param name="extractors">
google.com:RecipientToEmailExtractor
</Param>
</Require>
</ModulePrefs>
<!-- Define the content type and display location. The settings
"html" and "card" are required for all Gmail contextual gadgets. -->
<Content type="html" view="card">
<![CDATA[
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,900,900italic,700italic"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular.min.js"></script>
<script type="text/javascript">
function getSenderName() {
var matches = google.contentmatch.getContentMatches();
console.log("matches>>", JSON.stringify(matches));
try {
for (var match in matches)
for (var key in matches[match])
if (key == "sender_name") return matches[match][key];
}
catch (ex) {
console.error("getSenderName failed >>", ex);
}
return "no found";
}
function init(){
$("#content").text(getSenderName());
}
//gadgets.window.adjustHeight(50);
$(document).ready(function () {
console.log("Gmail Gadget Initializing ...");
gadgets.util.registerOnLoadHandler(init);
console.log("Gmail Gadget Initialized.");
});
</script>
Hello <span id="content"></span>
]]>
</Content>
</Module>