Search code examples
vbaoutlookmapioutlook-redemptionoutlook-2013

Mail Stuck in Outbox of Outlook 2013 sent using Redemption


Currently i am in a process of migrating applications to new version, i am facing a problem in the application. Basically its a VBA Access application which will send reports to users. For the mail delivery part it uses Redemption.dll

Current Versions:

  • Windows XP
  • MS Office 2003
  • Redemption.dll v 4.5.0.812

Migrating To

  • Windows 7

  • MS Office 2013

  • Redemption.dll v 4.5.0.812

Scenario 1: In Win 7 machine using the redemption.dll v 4.5.0.812 when i run the application, the report delivery function runs without errors. But what i noticed is the mails are stuck in Outbox. When i open Outlook 2013 the mails get delivered. So when i keep outlook open and run the function the mails get delivered.

Scenario 2: Now in Win 7 machine using the developer version redemption.dll v 5.14 too the mail get stuck in Outbox.

What could be the reason, is there need to do code changes or is it some setting changes related to Outlook 2013? Any kind of help would be very useful.... need it badly :-) If there is a need to do code changes, is it possible keeping the redemption.dll version v 4.5 (as per the requirement)

Let me know if you need more information.

Thanks


Solution

  • From http://www.dimastr.com/redemption/faq.htm#1

    When I send a message using Redemption, it simply stays in the Drafts folder

    Message submission is a two step process in Extended MAPI:

    1. Calling IMessage::Submit()

    2. Flushing the outgoing message queue.

    If you are using an Exchange Server, step #2 is not required since Exchange Message Store is tightly bound with the Exchange Transport provider. If you however are using a POP3/SMTP transport and a PST file as a message store, step #2 is required. To flush the message queues, create an instance of Redemption.MAPIUtils object and call its DeliverNow method (similar to Session.DeliverNow in CDO) after calling SafeMailItem.Send:

    MailItem.Send
    Set Utils = CreateObject("Redemption.MAPIUtils")
    Utils.DeliverNow
    

    There is however one problem if you are using Outlook 2002 or newer with a PST file and POP3/SMTP transport provider or Outlook 2000 installed in the Internet Only Mode: there is no way to flush the queues using Extended MAPI. That part of Outlook is simply broken. Note however that Outlook 2002/2003 (online) with an Exchange Server or Outlook 2000 C/W in any configuration are fine.

    If you are using Outlook 2003 or higher with Exchange in a cached mode, it will exhibit the same problem. Uncheck "Use cached mode" in the Exchange Server properties to force online mode - that will ensure that messages are delivered immediately.

    As a last resort, you can simulate clicking "Send/Receive" button in Outlook after sending a message:

    MailItem.Send
    Set Btn = Application.ActiveExplorer.CommandBars.FindControl(1, 5488) 
    Btn.Execute
    

    Note that in Outlook 2003 that button is now a dropdown, the real Send/Receive is a subitem of the button:

    Set Btn = Application.ActiveExplorer.CommandBars.FindControl(1, 7095)
    Btn.Execute
    

    Note that the code above assumes that there is an active Explorer; this will not be the case if you start Outlook programmatically (and it was not previously started by a user) and do not display any folders. In this case you can start a sync using the the Namespace.SyncObjects collection.:

     set NS = Application.GetNamespace("MAPI")
     NS.Logon
     Set Sync = NS.SyncObjects.Item(1)
     Sync.Start
    

    In Outlook 2010 you can also use Namespace.SendAndReceive method.