none
How to "gracefully" interrupt Outlook single thread RRS feed

  • Question

  • Hi

    I want to execute Outlook VBA macro upon modem received data (Ring).
    System.dll is unavailable so i tried cyclic timer based readfileno macro.
    This works unless collide with Outlook send/receive process which is executed periodically.
    The required solution should "gracefully" interrupt Outlook single thread.
    Can anyone suggest how i should do that

    Appreciate your advice


    • Edited by BR-99 Sunday, May 19, 2013 1:39 PM
    Sunday, May 19, 2013 12:17 PM

Answers

  • If sync events are handled one can subscribe to the SyncObject.SyncStart() event to know when a sync operation started, and SyncEnd() to know when it ends. If terminating a sync is desired a Stop() method call can be made in the SyncStart() event but it might not stop the initial sync item from being sent.
     
    There is no granularity to know when each item in the transmission has been sent.
     
    If using Redemption is an option each RDOMail item has an AbortSubmit() method that allows you to abort any sending of the item, that would need to be called perhaps when an item was sent or perhaps added to Outbox, although you have to be extremely careful when touching items in Outbox to make sure you don't abort sending them when you don't want to.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "BR-99" <=?utf-8?B?QlItOTk=?=> wrote in message news:ebf509af-6945-4ca9-886c-5dc0dbee586b...

    Your assumption is correct. I sent 2 mails, ran my code to find out that only one e-mail was sent.

    This brings me to ask if there is a way to withevents send completion ?

    Thanks


    Ken Slovak MVP - Outlook
    • Marked as answer by BR-99 Tuesday, May 21, 2013 4:51 PM
    Tuesday, May 21, 2013 1:27 PM
    Moderator

All replies

  • Thank you

    I'm getting compilation error for:

    Dim instance As _SyncObject
    instance.Stop()

    I can't find reference Microsoft.Office.Interop.Outlook.dll , am i missing something ?

    Can i use it within VBA macro code ?

    Do i loose e-mail which is stopped while being received ?

    Is there a way to query Outlook thread state ?

    I'm unhappy polling COM port (waiting for Ring) , event seems better solution however not possible with VBA
    What options  do i have ?

    Thanks




    • Edited by BR-99 Monday, May 20, 2013 10:55 AM
    Monday, May 20, 2013 9:19 AM
  • SyncObject is something that you get from Namespace object, so in code it should look something like this:

    Application.Session.SyncObjects.Item(1).Stop()

    of course it depends which sync object is currently running, so you will have to loop and check yourself.

    Yes, you can use it with VBA and no, you will not loose anything while interrupting this process. Not sure what do you mean by thread state, if status of synchronization, then the syncobjects are a way to go. Why don;t you use other language if you are unhappy with vba?

    Monday, May 20, 2013 5:39 PM
  • Thanks a lot

    I tried to abort sending process however the e-mail was sent completely

    here is my code

    Sub AbortSendRec()
    Dim NS        As Outlook.NameSpace
    Dim oSync     As Outlook.SyncObject
    Dim cAllSyncs As Outlook.SyncObjects
    Dim i         As Integer
    
    Set NS = Application.GetNamespace("MAPI")
     
    Set cAllSyncs = NS.SyncObjects
    
    'Send and Receive groups
    For i = 1 To cAllSyncs.Count
      Set oSync = cAllSyncs.Item(i)
      Debug.Print i, oSync.Name
      oSync.Stop
    Next
    
    Set NS = Nothing
    Set cAllSyncs = Nothing
    Set oSync = Nothing
    
    End Sub

    Does stop property support account types such as POP3 ?  start property though works fine.

    I appreciate your feedback




    • Edited by BR-99 Tuesday, May 21, 2013 5:39 AM
    Tuesday, May 21, 2013 4:15 AM
  • i have no idea, sorry. Quite probably when Outlook recieves Stop on syncobject it finishes current operation and then aborts further actions (just like cancel button in send and recieve popup).
    Tuesday, May 21, 2013 6:32 AM
  • Your assumption is correct. I sent 2 mails, ran my code to find out that only one e-mail was sent.

    This brings me to ask if there is a way to withevents send completion ?

    Thanks

    Tuesday, May 21, 2013 9:29 AM
  • not sure i understood your question but there are events on synobject for starting and ending synchronization. Is that what you wanted?
    Tuesday, May 21, 2013 12:40 PM
  • If sync events are handled one can subscribe to the SyncObject.SyncStart() event to know when a sync operation started, and SyncEnd() to know when it ends. If terminating a sync is desired a Stop() method call can be made in the SyncStart() event but it might not stop the initial sync item from being sent.
     
    There is no granularity to know when each item in the transmission has been sent.
     
    If using Redemption is an option each RDOMail item has an AbortSubmit() method that allows you to abort any sending of the item, that would need to be called perhaps when an item was sent or perhaps added to Outbox, although you have to be extremely careful when touching items in Outbox to make sure you don't abort sending them when you don't want to.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "BR-99" <=?utf-8?B?QlItOTk=?=> wrote in message news:ebf509af-6945-4ca9-886c-5dc0dbee586b...

    Your assumption is correct. I sent 2 mails, ran my code to find out that only one e-mail was sent.

    This brings me to ask if there is a way to withevents send completion ?

    Thanks


    Ken Slovak MVP - Outlook
    • Marked as answer by BR-99 Tuesday, May 21, 2013 4:51 PM
    Tuesday, May 21, 2013 1:27 PM
    Moderator