Results 1 to 10 of 10

Thread: [SOLVED] Can a zimlet send an email?

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    7

    Default [SOLVED] Can a zimlet send an email?

    Stoopid question perhaps: can a zimlet send an email "itself". That is - is there an API available to let a zimlet send an email as part of the various activities it's completing?

    Apologies in advance if this is a lame question - had a look and couldn't find out.

    Cheers,
    Sean

  2. #2
    Join Date
    Jul 2006
    Location
    Pisa
    Posts
    135
    Rep Power
    9

    Default

    I edited the message to show full code


    It_Seacom_Zimlet.prototype.getUserDisplayName =
    function() {
    if(!appCtxt.get(ZmSetting.DISPLAY_NAME)) return "";
    return appCtxt.get(ZmSetting.DISPLAY_NAME);
    };
    It_Seacom_Zimlet.prototype.getUserReplyTo =
    function() {
    return appCtxt.get(ZmSetting.REPLY_TO_ADDRESS);
    };

    It_Seacom_Zimlet.prototype._sendMsg =
    function(destName, destEmail, subject, body) {
    var soapDoc = AjxSoapDoc.create("SendMsgRequest", "urn:zimbraMail", "noSave=0");
    var m = soapDoc.set("m");
    m.setAttribute("idnt", this.userID);
    var node_e = soapDoc.set("e", null, m);
    node_e.setAttribute("p", this.getUserDisplayName() );
    node_e.setAttribute("a", this.getUserReplyTo());
    node_e.setAttribute("t", "f");
    node_e.setAttribute("p", destName);
    node_e.setAttribute("a", destEmail);
    node_e.setAttribute("t", "t");
    var node_s = soapDoc.set("su",subject , m);
    var node = soapDoc.set("mp", null, m);
    node.setAttribute("ct", "text/plain");
    var subnode = soapDoc.set("content", body, node);
    var command = new ZmCsfeCommand();
    var resp = command.invoke({soapDoc: soapDoc});
    var r = "Message sent";
    DBG.println(AjxDebug.DBG2, "result:" + r);
    this.displayStatusMessage(r);
    };
    Last edited by lfasci; 02-28-2008 at 10:44 AM.

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    7

    Default Thanks!

    Thanks - a quick follow-on question: that is JavaScript creating a SOAP request - right? Where would I find the API documentation for those Zimbra SOAP APIs?

    Cheers,

    Sean

  4. #4
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    The code is really documented.... in the code. Thanks for digging this far, I wonder if one of you would be so kind as to put this up on the wiki?

  5. #5
    Join Date
    Oct 2007
    Posts
    3
    Rep Power
    7

    Default Up on Wiki

    Happy to put it up on the Wiki. Will have a dig around and see where best to put that.

    Cheers,

    Sean

  6. #6
    Join Date
    Jul 2006
    Location
    Pisa
    Posts
    135
    Rep Power
    9

    Default SOAP docs

    You can find the SOAP docs here

    SourceForge.net Repository - [zimbra] Index of /trunk/ZimbraServer/docs

    pay attention some synta x is old.

  7. #7
    Join Date
    Mar 2007
    Location
    Ferrara, Italy
    Posts
    55
    Rep Power
    8

    Default

    Hey there

    In a few words: Lorenzo's perfect snippet lacks one feature though... Attachments! That's why I'm here now... :-(

    In soap.txt:
    Code:
    <SendMsgRequest [suid="{send-uid}"] [needCalendarSentByFixup="0|1"] [noSave="0|1"]>
      <m [origid="..." rt="r|w"] [idnt="{identity-id}"]>
        <e t="{type}" a="{email-address}" p="{personal-name}" [add="1"]/>+
        <su>{subject}</su>*
        [<irt>{Message-ID header for message being replied to}</irt>]
        <mp ct="{content-type}">
          <content>...</content>
        </mp>
    
        <attach [aid="{attach-upload-id}"]>
          [<m id="{message-id}"/>]*
          [<mp mid="{message-id}" part="{part-id}"/>]*
          [<cn id="{contact-id}"/>]*
        </attach>
    
      </m>
    </SendMsgRequest>
    I found the part I needed, I then started investigating what gives me the IDs I need here...

    Well, I'm pretty lost with "which does what, and where"...

    Have you ever published some of your internal dev schematics for the overall architecture (UML or something like that)? That would be pure gold for me...


    As far as I can see, I'm supposed to upload (how do I call the dialog?) a file (found various js files about the subject, but even there, kinda lost...) in zimbra on the dedicate fileuploadservlet. Then I should receive an attachment id (where?), and then I'll proceed in setting it inside the soapDoc.set("attach"...) call to attach whatever I want to the message.

    Is anybody so kind to address me in the right direction? I like to get dirty and wet (ehm... nevermind!): once on the right route, I'd be independent in proceeding further on, but this time it's a ocean too huge for me (at least for the time slices I'm dedicating to the project, considering that this is NOT my default job area...)

  8. #8
    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    4

    Default

    Even if thread is marked SOLVED , I'm still little lost in understanding how the sending mail thorugh zimlet mechanism works ...

    I'm trying to put place a button to reject a particular mail selected from the "mail pane" . Here's the code that should send a mail in response of rejection

    Code:
    com_example_rejectmsg_HandlerObject.prototype._rejectSelectedMail =
    function(controller) {
    
    	var message = controller.getMsg();
    	appCtxt.getAppController().setStatusMsg("Rejected:"+ message.subject);
    	
    	var rejection = new ZmMailMsg;
    	appCtxt.getAppController().setStatusMsg(rejection.toString());
    	
    	try{
    	var toV = new AjxVector ;
    	var fromV = new AjxVector;
    	
    	var fromAddr = new AjxEmailAddress("foo@example.com",AjxEmailAddress.FROM,"foo","foo",false);
    	fromV.add(fromAddr,0,true);
    	var toAddr = new AjxEmailAddress ("bar@example.com",AjxEmailAddress.TO,"bar","bar",false)
    	toV.add(toAddr,0,true);
    	}
    	catch(err)
    	{
    		alert(err.message)
    		alert(err.stack)
    	}
    	
    	try{
    	rejection.setAddresses(ZmMailMsg.HDR_FROM,fromV);
    	rejection.setAddresses(ZmMailMsg.HDR_TO,toV);
    	
    	rejection.setSubject("REJECTED - " + message.subject );
    	rejection.setTopPart("text/plain");
    	}
    	catch(err)
    	{
    		alert(err.message)
    		alert(err.stack)	
    	}
    	finally{
    	rejection.send(false,function(){appCtxt.getAppController().setStatusMsg("message sent");},function(){appCtxt.getAppController().setStatusMsg("message not sent");},null); 
    	}
    };
    Please do not consider the poor style in coding ( i.e. address hardcoded ) , it's my first javascript try and has the only purpose to understand of to send mail within a zimlet.

    Regards

  9. #9
    Join Date
    Feb 2012
    Posts
    30
    Rep Power
    3

    Default

    Any body knows if there is multiple recipient in to field, how to implement it?

  10. #10
    Join Date
    Feb 2012
    Posts
    30
    Rep Power
    3

    Default

    Finally get the answer.....

    var node_e = soapDoc.set("e", null, m);
    node_e.setAttribute("p", "a" );
    node_e.setAttribute("a", "a@abc.com");
    node_e.setAttribute("t", "f");
    var node_c = soapDoc.set("e", null, m);
    node_c.setAttribute("p", "b" );
    node_c.setAttribute("a", "b@abc.com");
    node_c.setAttribute("t", "t");
    var node_d = soapDoc.set("e", null, m);
    node_d.setAttribute("p", "b" );
    node_d.setAttribute("a", "d@abc.com");
    node_d.setAttribute("t", "t");

Similar Threads

  1. Replies: 21
    Last Post: 02-04-2010, 09:06 AM
  2. need advice on configuring zimbra to work with fax server
    By pheonix1t in forum Administrators
    Replies: 0
    Last Post: 07-11-2007, 07:46 PM
  3. Post instsallation problems
    By Assaf in forum Installation
    Replies: 14
    Last Post: 01-29-2007, 10:38 AM
  4. upgrade to 4.0.3 antispam does'nt work
    By lucanannipieri in forum Administrators
    Replies: 14
    Last Post: 11-07-2006, 02:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •