View Single Post
  #8 (permalink)  
Old 04-20-2011, 06:36 AM
TheRealKam TheRealKam is offline
Starter Member
 
Posts: 1
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
Reply With Quote