zimbra中的Zimlets,如何制作简单的SearchRequest?

时间:2015-08-11 06:01:21

标签: javascript json soap zimbra zimlet

我有点绝望,因为我无法对我的zimlet进行简单的搜索。

我只是想在自定义文件夹中进行搜索。

搜索应该只显示我的自定义文件夹中的邮件。

就像我点击左侧窗格中的自定义文件夹一样。完全一样。

这是通过在左窗格中按我的自定义文件夹的图标来显示html标题。

{"Header":{"context":{"_jsns":"urn:zimbra","userAgent":{"name":"ZimbraWebClient - FF39 (Linux)","version":"8.6.0_GA_1153"},"session":{"_content":150,"id":150},"account":{"_content":"admin@localhost.local","by":"name"},"csrfToken":"0_a3050edfdf238eadfdfdfdff2f14b4968e3"}},"Body":{"SearchRequest":{"_jsns":"urn:zimbraMail","sortBy":"dateDesc","header":[{"n":"List-ID"},{"n":"X-Zimbra-DL"},{"n":"IN-REPLY-TO"}],"tz":{"id":"America/Mexico_City"},"locale":{"_content":"es_MX"},"offset":0,"limit":100,"query":"in:\\"mycustomfolder\\"","types":"conversation","recip":"0","fullConversation":1,"needExp":1}}}

我正在尝试使用此代码,在我的com_zimbra_myzimlet.js中

com_zimbra_myzimlet_HandlerObject.prototype._getShowResultFolderId = 
    function(t) {
    var e=AjxSoapDoc.create("SearchRequest","urn:zimbraMail");
    var cuery="raulicci";
    e.setMethodAttribute("types","conversation");
    e.setMethodAttribute("limit",100);
    e.setMethodAttribute("offset",0);
    e.set("query",cuery);
    t.response=appCtxt.getAppController().sendRequest({
        soapDoc:e,noBusyOverlay:false}
    );
    this.handleSearchResponse(t)
};

到目前为止,我找不到一种方法来进行咨询,虽然我觉得它很简单,因为当你点击左窗格中我的自定义文件夹中的图标时,已经在zimbra中实现了。

1 个答案:

答案 0 :(得分:0)

我想使用具有zimbra的默认模板来显示INBOX或当前文件夹。

当您点击左侧窗格中当前文件夹的图标时,我们会将电子邮件列表显示为INBOX

我用我的小zimlet用soap和json做了一个查询,我回答了一个JSON字符串。

此字符串json是一个邮件列表,位于执行查询的文件夹中。

请求使用:

var jsonObj = {SearchRequest:{_jsns:"urn:zimbraMail"}};
var request = jsonObj.SearchRequest;
request.sortBy = "dateDesc";
request.offset = 0;
request.limit = 100;
request.query = 'in:\"MYCURRENTFOLDER\"';
request.types = "conversation";
request.recips = "0";
request.fullConversation = 1;
request.needExp = 1;

var params = {
        jsonObj:jsonObj,
        asyncMode:true,
        callback: (new AjxCallback(this, this._handleSOAPResponseJSON)),
        errorCallback: (new AjxCallback(this, this._handleSOAPErrorResponseJSON)),
};
return appCtxt.getAppController().sendRequest(params);

对于响应使用:

if (result.isException()) {
    // do something with exception
    var exception = result.getException();      

    return;
}
else {
    response = { _jsns: "urn:zimbraMail", more: false };
}
// do something with response (in JSON format)
var response = result.getResponse();
var name = response.name;
var soapURL = response.publicURL;
var soapURL = response.soapURL;
var aller = result.getResponse();
var searchResult = new ZmSearchResult(this);

appCtxt.setStatusMsg("Response (JSON) success - "+name);
alert(aller.toSource());

JSON响应将显示在INBOX集成zimbra的默认模板中

({SearchResponse:{sortBy:"dateDesc", offset:0, c:[{id:"314", u:0, n:2, f:"s", d:1438663876000, su:"lokitox", fr:"lex", e:[{a:"admin@localhost.local", d:"admin", t:"f"}], m:[{id:"313", l:"300"}, {id:"312", l:"5", f:"s"}], sf:"1438663876000"}, {id:"-309", u:0, n:1, d:1438662639000, su:"Daily mail report for 2015-08-03", fr:"Grand Totals -- messages 91 received 117 delivered 0 forwarded 134 deferred (134 deferrals) 169 bounced 0 rejected (0%) 0 reject warnings 0 held 0 ...", e:[{a:"admin@localhost.local", d:"admin", t:"f"}], m:[{id:"309", s:"7232", l:"300"}], sf:"1438662639000"}], more:false, _jsns:"urn:zimbraMail"}})

谢谢,我希望有人知道如何做到这一点