[Kde-pim] Kmail API: deleting emails from a kmail maildir folder.

Kevin Krammer krammer at kde.org
Fri Apr 20 17:00:38 BST 2012


Hi Augustin,

I recommend you subscribe to the KDE PIM developer mailing list and we 
continue the thread there.

On Friday, 2012-04-20, augustin wrote:
> Hello,
> 
> I'd like to write an application to help me programmatically  sort and
> delete some emails that are currently stored in maildirs belonging to
> kmail. (I mean kmail receives, handles and stores the emails, but I'd like
> a 3rd-party software to delete the emails under certain conditions).

What version of KMail / KDE PIM are you targetting?

In a KMail 2 / KDE PIM 4.7 setup programmatic access to e-mails is handled via 
Akonadi so any program can work with e-mail just like KMail itself does.

> I can write the application to browse the maildirs, and parse the MIME. I
> have found a couple of APIs that I might use (any recommendations?).

libkmime (kdepimlibs/kmime), libmaildir (kdepim-
runtime/resources/maildir/libmaildir)

> But where I am a bit uncertain, is how to handle the deletion of the
> emails. Deleting a specific email is certainly easy (delete the
> corresponding file), but what about regenerating indexes?

Depends on the targetted KDE PIM version.
With KMail 1 you can not do that, it assumes full ownership of its maildir 
tree.

With KMail 2 it depends on what Akonadi resource is handling the maildir tree.
The maildir resource can deal with file notifications (right Andras?), the 
"KMail Folders" (mixed maildir) resource can't do that yet.
However in the case of a KMail 2 setup, mail manipulation facilities are 
available for all programs, not just KMail.

> Wouldn't I be better off using some d-bus API? Let kmail perform the
> deletion itself? Does one d-bus API exist for email deletion?

I don't think there is such an API yet, but somebody else might know better.

> And by the way, where is the d-bus API for kmail documented? I searched but
> found nothing.

Most of the KMail D-Bus API is "internal", i.e. for communication between 
Kontact components. This is of course no reason not to document them but it 
means that they are not considered public API and can change at any time 
(AFAIK).

> Would you recommend any specific API to browse the maildirs, parse the MIME
> and, obviously, delete the emails from within my application?

On a KMail 2 system Akonadi::CollectionFetchJob, Akonadi::ItemFetchJob, 
Akonadi::ItemDeleteJob and KMime::Message.

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20120420/447110cd/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list