Avoid fatal error when the SQLite directory needs to be created

I was getting nasty fatal exceptions when I was trying to create a mapping from INBOX on exchange 2010 to gmail. Finally I realised the problem was not with the name of the exchange IMAP folder, but simply because the SQLite database file was being created in a directory which didn't yet exist!