Zimlet to Pre-Process Email

Interested in talking about Mash-up's? This is the place.
java_macchiato
Posts: 15
Joined: Fri Sep 12, 2014 11:23 pm

Zimlet to Pre-Process Email

Postby java_macchiato » Wed Apr 16, 2008 8:45 am

I would like to create a Zimlet that does some processing on an email before it is sent. Basically, when the user clicks the Send button, the Zimlet would need to do some action on the email text before the standard "Send" action is completed. I've made quite a few Zimlets now, so I'm no longer a rookie, but this has me stumped.
A lot of command-driven frameworks I've worked with allow you to add listeners to events. For example, you could subscribe to the "onSend" command and implement a doBeforeSend method. Can I do anything like this with Zimbra?


agnes
Posts: 39
Joined: Fri Sep 12, 2014 11:23 pm

Zimlet to Pre-Process Email

Postby agnes » Mon Jul 21, 2008 4:24 am

Did you find the way to do that? I need to do exactly the same thing. Anyone have some ideas ?
java_macchiato
Posts: 15
Joined: Fri Sep 12, 2014 11:23 pm

Zimlet to Pre-Process Email

Postby java_macchiato » Mon Jul 21, 2008 9:44 am

Yes, I did, but there was no elegant way to do it. I had to go in and edit the Zimbra source a little, which means that it breaks on every update. I have to go in an redo this by hand after each update.
Basically I wrote a JS class called MailProcessor as part of a Zimlet. Then near the end of at the end of ZmMailMsg.prototype.send in MailCore_all.js, add:


var arp = new MailProcessor();

arp.processEmail(params);


Then from the command prompt:
cp MailCore_all.js MailCore_all.js.

gzip -S zgz MailCore_all.js.
Do this at your own risk and not on a production server. The odds of breaking something along the way are high.
agnes
Posts: 39
Joined: Fri Sep 12, 2014 11:23 pm

Zimlet to Pre-Process Email

Postby agnes » Wed Jul 23, 2008 9:13 am

Yes, i was thinking about that. But I really didn't want to change anything in Zimbra source. So I found another solution, maybe not the best but it works for me.

I replaced the selection listener in a button 'Send' with my own so i could launch my function sendMsg() which is almost the same as a ZmComposeController.SendMsg - just before message is send I do some operations on it.
rrao
Zimbra Alumni
Zimbra Alumni
Posts: 187
Joined: Fri Sep 12, 2014 9:55 pm

Zimlet to Pre-Process Email

Postby rrao » Tue Mar 31, 2009 2:43 pm

In Zimbra 6.x I have added a hook to support pre-processing and we will have to wait for that to be released.
java_macchiato
Posts: 15
Joined: Fri Sep 12, 2014 11:23 pm

Zimlet to Pre-Process Email

Postby java_macchiato » Tue Mar 31, 2009 2:51 pm

Thanks! When the time comes, will you give us an example of how to use it?
rrao
Zimbra Alumni
Zimbra Alumni
Posts: 187
Joined: Fri Sep 12, 2014 9:55 pm

Zimlet to Pre-Process Email

Postby rrao » Tue Mar 31, 2009 3:51 pm

The function to override is emailErrorCheck. It is automatically called by Zimbra just before email is sent(after Send button is clicked). And waits to see if the function returns

"null" - in case of no-issues or

"{hasError:true, errorMsg:"your email has so and so issue", zimletName:"com_zimbra_checkEmail"}" - in case of any issue.
If there is any issue, Zimbra then shows a dialog:

"your email has so and so issue", do you wish to continue?

[Yes] [No]




com_zimbra_checkEmail.prototype.emailErrorCheck =

function(mail, boolAndErrorMsgArray) {



var bodyText = mail.getBodyContents();


if(hasError) {

return boolAndErrorMsgArray.push({hasError:true, errorMsg:"your email has so and so issue", zimletName:"com_zimbra_checkEmail"});

} else {

return null;//no errors

}

}


I am in the process of documenting all these things @ wiki.zimbra.com
7211webman
Advanced member
Advanced member
Posts: 152
Joined: Fri Sep 12, 2014 11:10 pm

Zimlet to Pre-Process Email

Postby 7211webman » Thu Apr 02, 2009 3:50 am

Will there be functionality available that will prevent the message from being sent until a certain condition has been met? I can see this being a great way to develop a more efficient content filter for school use, which will prevent students from sending out messages containing swear words.
Eg. instead of "Do you wish to continue - Yes/No" - could the Zimlet say, for example, "Cannot continue due to Error X - OK".
sarveshr
Posts: 2
Joined: Sat Sep 13, 2014 12:32 am

Zimlet to Pre-Process Email

Postby sarveshr » Wed Aug 12, 2009 6:34 am

Hi,
In the pre-processing operations, is it possible to change the content of message, e.g., text and attachment? If you have any clue, please help.
plaiad
Posts: 1
Joined: Sat Sep 13, 2014 2:19 am

Zimlet to Pre-Process Email

Postby plaiad » Tue Nov 08, 2011 5:51 am

Hi,
Could you explain agnes how do you succed in changing text containt before make a new request ?
Thx,

Return to “Zimlets”

Who is online

Users browsing this forum: No registered users and 2 guests