Mailing files with Thunderbird or KMail from Dolphin

Submitted by gunnar on

This guide describes how you create a service menu to allow you to right click a file in Dolphin and create a new mail with the file as an attachment.

The first thing you need to do is to locate and/or create the directory where service menu definitions should be located.
For KDE 4 you can use the command line tool kde4-config. Type the following on a command line:
  kde4-config --path services

On my SuSE 13.2 system I get the following output:

  /home/gugrim/.kde4/share/kde4/services/:/usr/share/kde4/services/

The first path shows where your personal ServiceMenus directory should be located. Check if there already is such a directory there, if not create it.

For Plasma 5 there is no such tool AFAIK but on my SuSE Leap 42.2 system it is

  /home/gugrim/.local/share/kservices5/ServiceMenus

In the ServiceMenus directory, create a new file called sendto.desktop with the following content:

[Desktop Entry]
Type=Service
Actions=SendToMailRcp
Encoding=UTF-8
MimeType=application/octet-stream
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
X-KDE-Priority=TopLevel
X-KDE-Submenu=Send To

[Desktop Action SendToMailRcp]
Name=Mail Recipient...
Exec=thunderbird -compose attachment="file:///%f"
Icon=thunderbird

If you use kmail instead of thunderbird, replace the last two lines with:

Exec=kmail --attach %F
Icon=kmail

For Plasma 5 you then need to run kbuildsycoca5 from the command line, or log out and log in again.

Start Dolphin and right click a file. You should now have a "Send To" submenu with a "Mail Recipient..." entry.

 

Useful article! To make it more integrated with dolphin in KDE 5, I changed some lines. This way the option appears as an alternative to the existing feature, that only works with KMail. I'm using Kubuntu 15.04.

[Desktop Entry]
Type=Service
Actions=sendto
Encoding=UTF-8
MimeType=application/octet-stream
X-KDE-ServiceTypes=KonqPopupMenu/Plugin

[Desktop Action SendToMailRcp]
Name=Send e-mail using Thunderbird
Exec=thunderbird -compose attachment="file:///%f"
Icon=thunderbird

To make it work for multiple files change the Exec line to:
Exec=thunderbird -compose "attachment='$(echo %F | sed 's/\\ \\//,\\/\\//g')'"
Thanks to: https://forum.kde.org/viewtopic.php?f=22&t=108244#p302205

Thomas Mahoney

Thu, 01/05/2017 - 16:43

I did that and it returns: kbuildsycoca5 running...
Reusing existing ksycoca
Recreating ksycoca file ("/home/chief/.cache/ksycoca5_en_SHI8dI3NCgJvQMxi74l5aL51968=", version 303)
Still in the time dict (i.e. deleted files) ("apps")
kf5.kservice.sycoca: Parse error in "/home/chief/.config/menus/applications-merged/xdg-desktop-menu-dummy.menu" , line 1 , col 1 : "unexpected end of file"
Menu "applications-kmenuedit.menu" not found.
The desktop entry file "/usr/share/applications/display-im6.desktop" has Type= "Application" but no Exec line
kf5.kservice.sycoca: Invalid Service : "/usr/share/applications/display-im6.desktop"
The desktop entry file "/usr/share/applications/display-im6.q16.desktop" has Type= "Application" but no Exec line
kf5.kservice.sycoca: Invalid Service : "/usr/share/applications/display-im6.q16.desktop"
Saving

Don't think you need to worry about those error messages, at least they don't seem to be related to the new service file. I also get a few error messages but then Plasma 5 is not quite production quality yet, IMO, so I'm not surprised.

works great for me.
and also thanks for the guy who shared his knowledge how it works with multiple files ( https://www.grim.se/comment/1029#comment-1029 )