Results 1 to 4 of 4

Thread: Sent mail in zimlet

  1. #1
    lix830917 is offline Junior Member
    Join Date
    Apr 2007
    Posts
    5
    Rep Power
    7

    Red face Sent mail in zimlet

    I'm a starter for zimbra,And I want to send a mail to certain address in my zimlet.What is the best way to do that?Could anyone show the detail in javascript or other.Thanks for attention!!!

    Com_hello_a.prototype.singleClicked = function(msgValue) {
    var view = new DwtComposite(this.getShell());
    var el = view.getHtmlElement();
    var div = document.createElement("div");
    var msgId = Dwt.getNextId();
    if (msgValue) {
    msgValue = msgValue.replace(/\x27/, "");
    msgValue = AjxStringUtil.htmlEncode(msgValue);
    }
    div.innerHTML=
    [ "To: <input id='rec' name='rec' type='text' \>" ,
    "message"<input id='file' name='file' type='text' \>"
    ].join("\n");
    el.appendChild(div)
    var dialog_args = {
    title : "Send this message?",
    view : view
    };
    var dlg = this._createDialog(dialog_args);
    dlg.popup();

    dlg.setButtonListener(DwtDialog.OK_BUTTON,
    new AjxListener(this, function() {
    sendmail();
    dlg.popdown();
    dlg.dispose();
    }));

    dlg.setButtonListener(DwtDialog.CANCEL_BUTTON,
    new AjxListener(this, function() {
    dlg.popdown();
    dlg.dispose();
    }));
    };

    function sendmail(){
    //what should I do here?
    }

  2. #2
    jholder's Avatar
    jholder is offline Former Zimbran
    Join Date
    Oct 2005
    Location
    Thatcher, AZ
    Posts
    5,606
    Rep Power
    20

    Default

    Is there any more in the Error Console (FF) or Debugger (IE)?

  3. #3
    JoshuaPrismon is offline Zimlet Guru & Moderator
    Join Date
    Nov 2005
    Posts
    477
    Rep Power
    9

    Default

    It's not quite as simple as the code above, but it's not horrifically complex. Anything having to do with the server usually is a SOAP call to the backend. The easiest way to figure that out is to grab firebug, and watch the network traffic to get a example. Then look it up in SOAP.txt

    The command you want to look at is SendMsgRequest

    Code:
    # origid will be present if this is a reply or forward
    # TODO: indicate whether to save in SentMail (or some other folder)
    
    +  add="1" on recipient email address means to add to caller's address book (no duplicate checking!)
    +  supports (f)rom, (t)o, (b)cc, (c)c, (r)eply-to "type" on <e> elements
    +  only allowed one top-level <mp> but can nest <mp>s within if multipart/*
    +  on reply/forward, set origid on <m> element and set rt to "r" or "w", respectively
    +  can optionally set identity-id to specify the identity being used to compose the message
    +  if noSave="1", a copy will *not* be saved to sent regardless of account/identity settings
    
    <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>
    The standard Zimbra code handles most of the header information (in particular the authtoken).

    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <userAgent name="ZimbraWebClient - FF2.0 (Win)" version="4.5.4_GA_763.FC4"/><sessionId id="111" />
    <change token="59553" type="new"/>
    <authToken>(REMOVED)</authToken>
    <format type="js"/></context>
    </soap:Header>
    What you need to construct is a SendMsgRequest:
    Code:
    <soap:Body>
    <SendMsgRequest xmlns="urn:zimbraMail" suid="1177704687970"><m idnt="2199a0c6-568b-11da-92a1-efa4f3028220"><e t="t" a="josh@hisdomain.com"/>
    
    <e t="f" a="josh@hisdomain.com" p="Joshua R. Prismon"/>
    <su>This is the message title</su>
    <mp ct="multipart/alternative">
    <mp ct="text/plain">
    <content>This is the message content  </content>
    </mp>
    <mp ct="text/html"><content>&lt;html&gt;&lt;head&gt;&lt;style type='text/css'&gt;body
    
     { font-family: 'Arial'; font-size: 12pt; color: #000000}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;This
    
     is the message content&lt;br&gt;&lt;/body&gt;&lt;/html&gt;</content></mp></mp></m></SendMsgRequest>
    
    </soap:Body></soap:Envelope>
    ZmCsfeCommand is the mechanism that you can use to send this directly to the server.

  4. #4
    lix830917 is offline Junior Member
    Join Date
    Apr 2007
    Posts
    5
    Rep Power
    7

    Default

    Thanks Lost,How can I get the sessionId and token's value?And how to fill or get the suid&idnt...
    In fact,I'm not very clear with these parameter.How can I get them in current state?
    Thanks again
    Last edited by lix830917; 04-28-2007 at 02:10 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problems with port 25
    By yogiman in forum Installation
    Replies: 57
    Last Post: 06-13-2011, 01:55 PM
  2. Replies: 7
    Last Post: 02-03-2011, 07:01 AM
  3. fresh install down may be due to tomcat
    By gon in forum Installation
    Replies: 10
    Last Post: 07-25-2007, 08:09 AM
  4. DynDNS and Zimbra
    By afterwego in forum Installation
    Replies: 30
    Last Post: 04-01-2007, 03:34 PM
  5. Mail not getting to mail boxes
    By ehults in forum Installation
    Replies: 5
    Last Post: 10-31-2005, 09:24 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
  •