[Android Software/Hacking General [Developers Only]] BillTheCat:
Interesting post.

I'm running an HTC Inspire with a custom ROM and my settings are different, which leads me to suspect that the fix requires a bit more than you indicate.

The path and file name you mention are not on my machine. I would guess it might differ based on your Android version (Froyo/Gingerbread/Honeycomb) and/or for any vendor who customizes Android, such as HTC's Sense or Motorola's Blur.

Under the VirtuousUnity ROM (a Pyramid/Sense3 port) that file is located at:

/data/data/com.htc.android.mail/databases/mail.db

In my 'accounts' table, the data seems to be organized differently than yours. I show the three IMAP accounts with 70 (yes, seventy) fields for each defining the behavior of each account for things such as (encrypted) password, refresh frequency, notification settings, and so on.

Among those 70 fields is '_sentfolderId' field, where it shows a numeric value corresponding to the below structure in the 'mailboxs' table in that same DB.

So, let's take my first IMAP address as an example. In the 'accounts' table, the '_sentfolderID' field displays '5' as the folder to use. That would seemingly correspond to the below convention in the 'mailboxs' table. If all there was to it would be to change the '5' to '7', I'd say it's a walk through the park. But I think not.

Here's where things get interesting.

In the 'mailboxs' table, the structure is far more complex. In that table, I show a minimum of 11 settings (rows) for each ID. They appear thus:

1 - INBOX

2 - Trash

3 - Drafts

4 - Outbox

5 - Sent

6 - INBOX.Drafts

7 - INBOX.Sent

8 - INBOX.Trash

9 - INBOX.Junk

10 - INBOX.Sent Items

11 - INBOX.Spam

(I say 'minimum' because one of my IMAP accounts used for business has additional folders added for organizational reasons, so I won't include them here in an effort to not confuse matters.)

However, I think there's more to it. For each record (listed above) there are 20 fields in my db corresponding thus:

_id (i.e.: 'INBOX', 'Trash', 'Drafts', etc.)

_undecodename

_decodename

_shortname

_serverfolder

_defaultfolder

_account

_movegroup

_showsender

_lastuid

_existsize

_noselect

_haschild

_serverid

_parentid

_displayname

_type

_synckey

_enablesync

_default_sync

For the first five records (a/k/a, '_id'), I show a numeric value in the '_defaultfolder' field thus:

2147483647

2147483646

2147483644

2147483643

2147483645

These '_defaultfolder' values are the same for each of my accounts - in other words, the set of 5 values appear for each of my accounts. There are also flags in other fields, but I think that the key is somewhere in the above settings. I have to believe there's a simple fix to this (like just changing the folder id settings to add or move the numeric value above to the 'INBOX.Sent' or 'INBOX.SentItems' field) but I'd like to hear from someone else before I take the plunge.

Perhaps I'll do a nandroid backup and experiment a bit, but if anyone else has some input, I'd really appreciate it because this is a problem that affects us all and is, in my view, inexcusable for Google or any phone vendor to not remedy.

Anyone else have thoughts on this?