Bug 75866

Summary: rename sent-messages folder at start of month
Product: [Unmaintained] kmail Reporter: Bjoern Bendix <lefty>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED WAITINGFORINFO    
Severity: wishlist CC: aaron.nixon, luigi.toscano, snairl
Priority: NOR    
Version: 1.6   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Bjoern Bendix 2004-02-22 21:42:27 UTC
Version:           1.6 (using KDE 3.2.0, SuSE)
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-166-default

Automatic copy the sendmail folder every month to sendmail-*month* like pine do it.
Comment 1 groot 2004-04-11 17:14:48 UTC
Changed to JJ; this requires a check on startup as well as a timer, because I tend to leave my kmail open and running for weeks on end (and don't forget, moving the sent-messages folder out from under someone is probably bad).
Comment 2 Thorsten Staerk 2004-06-23 13:13:51 UTC
please do not do this, if I search for a sent message, I do not know everything about it (else, I would not search for it). The first thing I forget is when I sent it. With this extension, I would have to look in 12 folders per year.
Just sort after date in your sent folder.
why make a simple thing complicated ?
Comment 3 Will 2004-06-29 16:17:44 UTC
Of course, something like this should be optional. Some users like to search an entire folder, others would like to split it up. Just a checkbox in the options section would be sufficient.
Comment 4 Krishna Sethuraman 2004-06-29 23:18:37 UTC
I'd prefer along with the monthly option, to do it quarterly, semiannually, or annually (or maybe these as quick choices with an option to specify an exact time period).  I like pine's mechanism of monthly, but I personally would have it work on an annual basis.
Comment 5 Andrius Kazimieras Kasparavičius 2004-09-26 09:40:56 UTC
well, it would be enormous perfect here to have full hierarchy(multi tree) for sorting out mails and having [multi]customized views like:

persons A kmail:
firstly sort by direction(inbox,outbox,drafts,sent-mail)
secondly by date(option to group dynamically or statically(f.e. by 3months))
thirdly by folders filters(Dick incoming, Mike incoming, Dick sent-mail, Mike sent-mail..)

persons B kmail:
firstly by date(option to group dynamically or statically(f.e. by 3months))
secondly sort by direction(inbox,outbox,drafts,sent-mail)
thirdly by folders filters(Dick incoming, Mike incoming, Dick sent-mail, Mike sent-mail..)

and so on.. is it clear?
Comment 6 Marc-Antoine Avon-Charreyron 2004-10-18 05:14:27 UTC
I've started working on this.  I've implemented it in the KMAccount class and the method is called by the KMKernel through an iteration of the accounts.  It works fine on a local sent folder but doesn't on an Imap account.  It doesn't crash or anything it just doesn't check the emails in that sent folder.  Anyone has any idea on this?
Comment 7 Carsten Burghardt 2004-10-18 09:45:48 UTC
Hard to say without code ;-) Can you provide a sample?

Comment 8 Marc-Antoine Avon-Charreyron 2004-10-18 17:37:47 UTC
Yeah I guess code might help :D

-thisMonth is called in the KMKernel constructor and determines the present month to check if it has changed
-A timer is created in KMKernel to check if the month has changed and if so it calls KMKernel::moveSentMail()

void KMKernel::moveSentMail()
{
  int doMove=-1;
  
  doMove = KMessageBox::questionYesNo(0, i18n("Move sent mail to a monthly folder?"));
         if (doMove == KMessageBox::No)
            return;
 
  QStringList actList = acctMgr()->getAccounts(false);
  QStringList::Iterator it( actList.begin() );
  for( ; it != actList.end() ; ++it ){
    acct = acctMgr()->findByName(*it);
    acct->moveSentMail(thisMonth);
}

void KMAccount::moveSentMail(int month)
{
  int i, count, doMove=-1; 
  char date[8];
  KMMsgBase *email;
  KMMessage *msg;
  KMFolderDir *fldrDir;
  KMFolderNode *node;
  KMFolder *newFldr;
  time_t t;
  struct tm *mTime;
  
  sentFldr->open();
  count=sentFldr->count(true);
  for(i=0; i<count; i++){
      email = sentFldr->getMsgBase(i); 
      t = email->date();
      mTime = localtime(&t);
    
      if(month != mTime->tm_mon){
         if(doMove != KMessageBox::Yes)
            doMove = KMessageBox::questionYesNo(0, i18n("Move sent mail to a monthly folder?"));
         if (doMove == KMessageBox::No)
            return;
      msg = sentFldr->getMsg(i);
         if((fldrDir=sentFldr->child()) == 0)
           fldrDir=sentFldr->createChildFolder();
         snprintf(date, 8, "%d-%02d", ((mTime->tm_year)+1900), (mTime->tm_mon));
         node=fldrDir->hasNamedFolder(i18n(date));
    
      if(node==0)
           newFldr=fldrDir->createFolder(i18n(date), false, KMFolderTypeMbox);
      else
           newFldr=(KMFolder*)node;
    
      newFldr->moveMsg(msg);
      count=sentFldr->count(true);
      i=-1;
      }
   }
}

Any other suggestion/criticism would welcomed, has this is the first time I'm writing a patch so I'm not too sure about conventions and so. For example i'm not sure if my code is in the right class or if it should be divided so code in each one is not too long, etc...
Comment 9 Marc-Antoine Avon-Charreyron 2004-10-19 03:46:59 UTC
I just realised that kmail doesn't store the sent mail on the imap sent folder.. the only reason why I have mail on that imap sent folder is because I sometimes use Thunderbird and other software at school.  And so I guess Kmail doesn't see that imap sent folder as a sent folder (it actually doesn't even have the "sent-mail" icon).  Now, I don't think there is any way to consistently get the imap sent folder because mine is called "sent" instead of "sent-mail" and we can't guess what name it will be on what account (I could rename it "my super duper sent-mail" for example).  Can anyone confirm if i'm right?
Comment 10 Till Adam 2004-10-19 08:43:03 UTC
On Tuesday 19 October 2004 03:47, Marc-Antoine Avon-Charreyron wrote:

> I just realised that kmail doesn't store the sent mail on the imap
> sent folder.. the only reason why I have mail on that imap sent folder is
> because I sometimes use Thunderbird and other software at school.  And so I
> guess Kmail doesn't see that imap sent folder as a sent folder (it actually
> doesn't even have the "sent-mail" icon).  Now, I don't think there is any
> way to consistently get the imap sent folder because mine is called "sent"
> instead of "sent-mail" and we can't guess what name it will be on what
> account (I could rename it "my super duper sent-mail" for example).  Can
> anyone confirm if i'm right?

You can configure a sent mail folder (including ones on imap) for each 
identity. To find out in code if a folder is a sent mail folder, use:

KMKernel::folderIsSentMailFolder( const KMFolder * folder )

Does that help?

Comment 11 Carsten Burghardt 2004-10-19 09:51:26 UTC
Some comments:
- as you're working with the accounts this might be better located in the
account manager IMO
- this is c++ and not c so there is no need to declare your variables
beforehand
- this won't work with imap as you first have to create the folder on the
server and then local so the process needs to be asynchronous. Have a look
at the folder creation in kmfolderdia.
- check your coding style with http://korganizer.kde.org/develop/hacking.html


Happy hacking ;-)

Comment 12 Andrew Morton 2005-11-22 15:43:39 UTC
I THINK YOUR A TWAT
Comment 13 Hans Dembinski 2007-04-20 06:23:08 UTC
Please don't do this. I'd also hate the idea to search multiple sent folders for message.

Better solution + very intuitive:

Make the search bar understand search requests like
"June 2000" or "from April to May", "April - May", "last week", "yesterday" and so on.

I volunteer!
Comment 14 greatbunzinni 2008-02-19 17:05:44 UTC
I don't see where exactly is there a need to implement this feature in kmail. It is better to store all sent emails in a single directory and then filter out the information as you see fit, including date. If you start splitting those emails up then you will lose the power to easily go through your emails. 

Moreover, if you believe you absolutely need this feature then, as all emails are stored in plain text format, it is very easy to write a small script that goes through the emails in any directory and move out those which fall into some category, including date sent. Why not give it a try?

On the other hand, as this wishlist report basically stood still since 2005, then I do believe that no one really wants this feature.
Comment 15 Aaron Nixon 2008-10-13 09:38:07 UTC
Just thinking, perhaps the mail boxes could have meta-filters, such that it may appear as:

Sent Items (Last 30 Days)
Sent Items/Last 30 Days (default)
Sent Items/Last Month
Sent Items/All

Or whatever, perhaps all folders could have meta-filters, I personally think I could find such a thing useful (Having tons of email is something I do personally).

Maybe I'll take a look at something like this.
Comment 16 Borislav Nedelchev 2008-11-06 22:01:43 UTC
Hi Guys,

can you explain me how to get started with the JJ, please?

Regards
Boris

p.s. sorry for the spam
Comment 17 Myriam Schweingruber 2012-08-18 08:48:08 UTC
Thank you for your feature request. Kmail1 is currently unmaintained so we are closing all wishes. Please feel free to reopen a feature request for Kmail2 if it has not already been implemented.
Thank you for your understanding.
Comment 18 Luigi Toscano 2012-08-19 00:55:54 UTC
Instead of creating a new feature request, please confirm here if the wishlist is still valid for kmail2.