diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 48970dd9d1f9..507549096f60 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -1687,6 +1687,11 @@ nsImapMailFolder::DeleteSubFolders(nsISupportsArray* folders, nsIMsgWindow *msgW if (!msgWindow) return NS_ERROR_NULL_POINTER; nsCOMPtr docShell; msgWindow->GetRootDocShell(getter_AddRefs(docShell)); + //If we can't find the trash folder and we are supposed to move it to the trash + //return failure. + if((NS_FAILED(rv) || !trashFolder) && !deleteNoTrash) + return NS_ERROR_FAILURE; + nsCOMPtr dialog; if (docShell) dialog = do_GetInterface(docShell); if (!deleteNoTrash)