Very often users need to do same actions on mail messages, and will be good to have ability for automate those actions. For example: - Create todo or event in external system (not KDE) - Create ticket in CRM with mail message body and title - Execute script that parse message body and do some actions - etc So will be good to have custom items in right-click menu on message in message list, in which we can write custom script, use tokens with message id, body, text, etc. Reproducible: Always
We have plugin support for interface in 5.2 now (new features). I can improve it to add support for external script. Now we need to define how to specify that we need body, title etc. So perhaps plugin provide script name and we can use %t for title (=> I replace %t by title mail) %b (body) etc. What do you think about it ?
Git commit db7b7417f3cec5acec2f31d8cc7721437344792f by Montel Laurent. Committed on 28/03/2016 at 12:00. Pushed by mlaurent into branch 'master'. Improve api to support future script support M +1 -1 CMakeLists.txt M +2 -2 messageviewer/src/viewerplugins/viewerplugininterface.cpp M +1 -1 messageviewer/src/viewerplugins/viewerplugininterface.h M +2 -2 messageviewer/src/viewerplugins/viewerplugintoolmanager.cpp http://commits.kde.org/messagelib/db7b7417f3cec5acec2f31d8cc7721437344792f
Thanks for quick reply! About replacements - maybe will be better to reuse replacement tokens from Template editor (and maybe part of program code) in Message Composer? %FULLSUBJECT %FROMADDR %FROMNAME %TEXT etc.
Also Tempalte editor already have "Process with External Programs" functional, maybe you can reuse it too.
When we have a script we need to parse argument so "script.sh -b<body> -t<title>" etc. We can't use directly %TEXT etc as we can't parse it.
If you send params via command line - yes, better use like %t, but very often message body contains multiple line and long text, so pipe this via external program ("Process with External Programs" like in templates) will be better way, because we can setup custom template and parse it in program side, for example: Command line: script.sh Input template: --- MESSAGE_TITLE: %FULLSUBJECT MESSAGE_TEXT: %TEXT CLIENT_NAME: %FROMNAME --- What do you think about this?
How you can create "Create ticket in CRM with mail message body and title" ? if you don't have arguments ?
I plan to create custom cli script like crm_create_ticket.php with something: <?php $input = file_get_contents("php://stdin"); preg_match('/^CLIENT_NAME: (.*)$/', $input, $matches); $client_name=$matches[1]; preg_match('/^MESSAGE_TITLE: (.*)$/', $input, $matches); $post['ticket_title']=$matches[1]; preg_match('/^MESSAGE_TEXT: (.*)$\nCLIENT_NAME/', $input, $matches); $post['ticket_body']="Client name: $client_name \n Query: \n $matches[1]; curl_setopt($curl, CURLOPT_URL, 'http://mycrm.com/create_ticket.php'); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post)); $out = curl_exec($curl); echo $out; curl_close($curl); ?> Or maybe bash equivalent of this process. So if KMail provide way to exec scripts and send message values to stdin of script, there will be wide way for customisation and automation of mail processing.
I look at the KMail and seems that we already can do this via Filters functional! In filters interface there are available Filter Actions "Pipe Throuth" and "Execute command" options. I place myscript.sh in "Execute command" - it gets all message source to stdin! Problem is only with parsing message subject and text, because they are BASE64 encoded, because we have raw message source text, not parsed via kmail.
And we can add created filters to right-click menu of message, buttons on toolbar. So seems this feature request is already available, but will be good to improve it via templates, that will sent to stdin of "Execute command" options.
(In reply to Murz from comment #9) > I look at the KMail and seems that we already can do this via Filters > functional! > > In filters interface there are available Filter Actions "Pipe Throuth" and > "Execute command" options. > > I place myscript.sh in "Execute command" - it gets all message source to > stdin! > > Problem is only with parsing message subject and text, because they are > BASE64 encoded, because we have raw message source text, not parsed via > kmail. yep filter allows it indeed.
(In reply to Murz from comment #10) > And we can add created filters to right-click menu of message, buttons on > toolbar. So seems this feature request is already available, but will be > good to improve it via templates, that will sent to stdin of "Execute > command" options. so it's another bug report it.
But this feature is still useful as we can send some specific info from email to a external script.