问题
I’m developing a gmail contextual gadget to get name and email of sender’s email, but I have problem to get name of sender.I tried different ways:
1.Using Custom Extractor
It seems obsoleted and I can not find where I can upload my manifest.xml with custom extractor at “Google Apps Marketplace SDK”. Any Idea!!??
2. Using pre-canned extractors
I defined google.com:SenderEmailExtractor and select “Mail-Sender Address and Mail-Sender Name” scope.Unforthunatly, I just get sender’s email in google.contentmatch.getContentMatches() but there is nothing related to sender’s name! What am I missing?
<?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>
来源:https://stackoverflow.com/questions/40874194/getting-the-sender-name-in-gmail-contextual-gadget