This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Keep new Header in my reply message when saving it as draft

Tags: None
(comma "," separated)
stefben
Registered Member
Posts
3
Karma
0
Hello

I'm trying to get a specific header 'X-Apparently-To' and its value from a received message in Kmail and save it in the reply of that message for further use and to complete the "From" field of my reply.

To get the header into my reply, I modified the following method this way:
MessageFactory::MessageReply MessageFactory::createReply()
Code: Select all
+                const QString xApparentlyTo = m_origMsg->headerByType("X-Apparently-To")->asUnicodeString();
+                KMime::Headers::Generic *header = new KMime::Headers::Generic( "X-Apparently-To", msg.get(), xApparentlyTo, "utf-8" );
+                msg->setHeader( header );


I'm able to modify the From field according to my wishes, but the Header "X-Apparently-To" is not kept in the reply when I save it as a draft :-\ . I must be missing something somewhere during the saving of the reply because when debugging, the header seems to be in the reply-message object anyway.

How can I achieve the header to be saved in the draft ? :)

I'm using Kmail from KDEPIM 4.14 (debian jessie)
User avatar
einar
Administrator
Posts
3402
Karma
7
OS
You want this header only on specific messages? Because in Configure KMail > Compose > Headers, you can set specific headers when composing.


"Violence is the last refuge of the incompetent."
Image
Plasma FAQ maintainer - Plasma programming with Python
stefben
Registered Member
Posts
3
Karma
0
Actually I want this Header to contain different values depending on some header of the message I reply to.

Concerning your suggestion about the custom headers, I tried to figure out where these custom headers are managed in the code, but I noticed that custom headers are never saved in the draft message although they appear in the message that is sent. That's probably a bug. (BTW, are you able to reproduce this ? Is this by design, or a bug that I should report ?)

Nevertheless I found out the place where it is necessary to specify the headers that have to be saved in the draft message. It has to be done in the following method of file messagecomposer/composer/composerviewbase.cpp
Code: Select all
void MessageComposer::ComposerViewBase::fillInfoPart ( MessageComposer::InfoPart* infoPart, MessageComposer::ComposerViewBase::RecipientExpansion expansion )

Adding these lines at the end of the method fixed my problem.
Code: Select all
+    if( m_msg->headerByType( "X-Apparently-To") )
+        extras << m_msg->headerByType( "X-Apparently-To");


Kind regards
User avatar
einar
Administrator
Posts
3402
Karma
7
OS
While this fixed it for you, you may want to file a wishlist on bugs.kde.org to have the matter generalized (although it won't happen soon, because PIM is in hard feature freeze).


"Violence is the last refuge of the incompetent."
Image
Plasma FAQ maintainer - Plasma programming with Python


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]