Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Zimlets

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-26-2007, 04:26 AM
Junior Member
 
Posts: 5
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?
}
Reply With Quote
  #2 (permalink)  
Old 04-26-2007, 10:52 AM
Former Zimbran
 
Posts: 5,606
Default

Is there any more in the Error Console (FF) or Debugger (IE)?
Reply With Quote
  #3 (permalink)  
Old 04-27-2007, 02:26 PM
Zimlet Guru & Moderator
 
Posts: 467
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.
Reply With Quote
  #4 (permalink)  
Old 04-27-2007, 07:43 PM
Junior Member
 
Posts: 5
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..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.