Bug 514044

Summary: External Script Plugin %body argument is always empty for HTML mails
Product: [Applications] kmail2 Reporter: Juriën Huisman <jurien>
Component: commands and actionsAssignee: kdepim bugs <pim-bugs-null>
Status: ASSIGNED ---    
Severity: minor CC: montel
Priority: NOR    
Version First Reported In: 6.6.0 (25.12.0)   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Juriën Huisman 2026-01-01 15:06:44 UTC
SUMMARY
When using the %body argument to an external script, the %body argument is always empty instead of containing the body/contents of the selected mail on which the external script is run. I have tried both HTML and plaintext mails.   

STEPS TO REPRODUCE
0. Create a script that allows you to see the %body argument, for example:
```
#!/bin/bash
kdialog --passivepopup "$1" 10
``` 
1. Go to `Settings`->`Configure KMail`->`Plugins` 
2. Enable the 'External Script' plugin (checkbox) and click the configure button
3. Click Add Script
4. Fill in a name and for Executable pick your script
5. Add %body in the argument field (just %body without quotes)
6. Click OK and apply the changes
7. Right click on a message -> External Script -> Name you gave the script

OBSERVED RESULT
The kdialog pop up appears, but is empty. 
Using #1 in the script shows that there is an argument (number of arguments = 1), but apparently it filled with an empty string?
Other values such as %s and %from work as expected.

EXPECTED RESULT
The %body argument should not be empty => the KDialog pop up window should show the body/content of the selected mail.

SOFTWARE/OS VERSIONS
KDE Plasma Version:  6.5.4
KDE Frameworks Version: 6.21.0
Qt Version: 6.10.1

ADDITIONAL INFORMATION
Comment 1 Laurent Montel 2026-01-01 15:20:42 UTC
I will look at it.
Regards
Comment 2 Juriën Huisman 2026-01-01 19:09:20 UTC
Correction, it does work for plaintext e-mails, but not HTML e-mails.
Comment 3 Laurent Montel 2026-01-02 10:03:13 UTC
I confirm it
Comment 4 Laurent Montel 2026-01-05 07:01:50 UTC
Git commit 27cb390bcc57f2d8d2349751fb8c61409eccf19f by Laurent Montel.
Committed on 05/01/2026 at 07:01.
Pushed by mlaurent into branch 'master'.

Fix External Script Plugin %body argument is always empty for HTML mails

Not perfect yet but allow to return not empty text

M  +8    -2    plugins/messageviewerplugins/externalscriptplugin/viewerpluginexternalscriptparseargument.cpp

https://invent.kde.org/pim/kdepim-addons/-/commit/27cb390bcc57f2d8d2349751fb8c61409eccf19f