Bug 298126 - In Offline mode, message sent via MAPISendMail will not save the unsent mail in Outbox (Unsent Messages). r=bienvenu,a=Standard8
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 03 Apr 2012 21:18:11 +0100
changeset 10695 c1bb6edc45e29958db812c4db37c5387a4635abe
parent 10694 dd4c013f2477484ae2615f805ac9c4866767cf8f
child 10696 934cea1f8fcfd25061f2c0b881c25509afd9d846
push idunknown
push userunknown
push dateunknown
reviewersbienvenu, Standard8
bugs298126
Bug 298126 - In Offline mode, message sent via MAPISendMail will not save the unsent mail in Outbox (Unsent Messages). r=bienvenu,a=Standard8
mailnews/mapi/mapihook/src/msgMapiHook.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -73,16 +73,17 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsIDirectoryService.h"
 #include "nsMsgI18N.h"
 #include "msgMapi.h"
 #include "msgMapiHook.h"
 #include "msgMapiSupport.h"
 #include "msgMapiMain.h"
 #include "nsThreadUtils.h"
+#include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 
 #include "nsEmbedCID.h"
 
 extern PRLogModuleInfo *MAPI;
 
 class nsMAPISendListener : public nsIMsgSendListener
 {
@@ -373,17 +374,19 @@ nsresult nsMapiHook::BlindSendMail (unsi
   nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
   if (NS_FAILED(rv) || (!pMsgCompose) ) return rv ;
 
   /** initialize nsIMsgCompose, Send the message, wait for send completion response **/
 
   rv = pMsgCompose->Initialize(pMsgComposeParams, hiddenWindow, nsnull);
   if (NS_FAILED(rv)) return rv ;
 
-  return pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, pMsgId, nsnull, nsnull, nsnull) ;
+  // If we're in offline mode, we'll need to queue it for later. No point in trying to send it.
+  return pMsgCompose->SendMsg(WeAreOffline() ? nsIMsgSend::nsMsgQueueForLater : nsIMsgSend::nsMsgDeliverNow,
+			      pMsgId, nsnull, nsnull, nsnull);
   if (NS_FAILED(rv)) return rv ;
 
   // assign to interface pointer from nsCOMPtr to facilitate typecast below
   nsIMsgSendListener * pSendListener = sendListener ;
 
   // we need to wait here to make sure that we return only after send is completed
   // so we will have a event loop here which will process the events till the Send IsDone.
   nsCOMPtr<nsIThread> thread(do_GetCurrentThread());