gnome-gmail – “Unable to determine IMAP Drafts folder location” solution

If you are getting the error “Unable to determine IMAP Drafts folder location” when you try to send an email with attachment you need to hardcode the Gmail Drafts folder location into the script. Mostly this is the case if you are using localized version either of Gnome or Gmail and the language settings doesn’t match.

You need to modify the script located in /bin/gnome-gmail.

For English version of Gmail the path should look like this:
folder_name = ‘[Gmail]/Drafts’
For Czech version like this:
folder_name = ‘[Gmail]/Koncepty’

For other languages you will have to experiment and find out the right translated name of the IMAP folder.

The following excerpt from the script is starting on the line 171:

            # I may need this again someday
            #folder_name = _("Drafts")
            folder_name = '[Gmail]/Drafts'

            # xlist returns directories e.g. 
            #    (\HasNoChildren \Drafts) "/" "[Gmail]/Drafts"
            # where the first "Drafts" is a flag, and the second is localized
            #drafts_ln = [ x for x in imap_obj.xlist()[1]
            #                         if ' .Drafts\)', x ) ][0]

            #draft_folder = '\"([^\"]+)\"$', drafts_ln ).group(1)

            raise GGError( _("Unable to determine IMAP Drafts folder location") )

            # upload the message to the Drafts folder
            #append_resp = imap_obj.append( draft_folder, None, None, self.message_text )
            append_resp = imap_obj.append( folder_name, None, None, self.message_text )
            raise GGError( _("Error encountered while uploading the message") )

            # get the Google Message Id for the message, and convert to a hex string
            # nods to

            # the append returns something like ('OK', ['[APPENDUID 9 3113] (Success)'])
            msg_uid = r'UID [0-9]+ ([0-9]+)', append_resp[1][0]).group(1)

   draft_folder )
   folder_name )
            typ, data = imap_obj.uid( r'fetch', msg_uid, r'(X-GM-MSGID)')

            msgid_dec = r'X-GM-MSGID ([0-9]+)', data[0] ).group(1)
            msgid_hex = hex( int( msgid_dec ) )
            msgid_hex_strp = r'0x(.+)', msgid_hex ).group(1)
            raise GGError( _("Error accessing message. Check the Drafts folder") )