Re: Copy email to file.

Ingo Klöcker <[email protected]>
Newsgroups gmane.comp.kde.users.pim
Message-ID <[email protected]>
On Friday 28 November 2008, John Culleton wrote:
> I want to create a filter such that a particular email is copied to a
> system folder (not a mail folder) and then as a  second action a
> program is executed.
>
> How do I make the filter copy the email to a file in a  regular
> folder, e.g., /usr/local/foo?

One possibility is to use the "Execute Command" filter action (cf. 
http://docs.kde.org/kde3/en/kdepim/kmail/filters.html#filter-action). 
Attached is a very simple Perl script which copies the message (read 
from STDIN) to a file. After writing the message to a file the Perl 
script could execute the second action.

If you do not want KMail to block (while the command is executed) then 
append '&' to the command. Note, that in this case you have to make 
sure that you do not overwrite the copied message with another one. So 
you might want to use mktemp to create the file name of the copied 
message.


Regards,
Ingo

_______________________________________________
KDE PIM users mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kdepim-users
copyMessageToFile.pl (application/x-perl, 145 B)
#! /usr/bin/perl -w
my @email = <STDIN>;
open FILE, ">/usr/local/foo/message.txt";
foreach $line (@email)
{
    print FILE $line;
}
close FILE;
signature.asc (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEABECAAYFAkkyzMAACgkQGnR+RTDgudhCqQCgt0+NWetfQ7jBz6C39ZIPG7fH
PhUAniSGSuU6ksWpTNHrJb1lK8cw3FbS
=Na59
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.