Once again, I am really grateful for your help!!
The problem I get is that the link stays grayed out.
If I put the button on the toolbar with this code it works:
$this->add_button(array(
'command' => 'plugin.telenormarkasjunk.junk',
'imagepas' => $skin_path.'/junk_pas.png',
'imageact' => $skin_path.'/junk_act.png',
'title' => 'telenormarkasjunk.buttontitle'), 'toolbar');
But if i put the button on the markmenu with this code it doesn't work (the class attribute never gets set to "spamlink active" when I choose a message in the messages list).
$button = $this->api->output->button(array(
'command' => 'plugin.telenormarkasjunk.junk',
'class' => 'spamlink',
'classAct'=>'spamlink active',
'label' => 'telenormarkasjunk.buttondesc'));
$this->api->add_content(html::tag('li', null, $button), 'markmenu');