--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:4EF3FA8F-5A04-4887...@microsoft.com...
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:49D368EE-34C3-4275...@microsoft.com...
________________________________________________________________
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Public Interface SyncObjectEvents
End Interface
Public bSendReceiveEnded As Boolean
'Private WithEvents objDefaultSendReceive As Outlook.SyncObject
Sub instance_SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub
Sub Main()
On Error Resume Next
' Create an Outlook application.
Dim i As Integer
Dim myTimer As New System.Timers.Timer()
myTimer.Interval = 3000
Dim oApp As Outlook._Application = New Outlook.Application
' Create the name space.
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects
Dim oSync As Outlook.SyncObject
Dim instance As SyncObjectEvents
Dim myAPF = oNS.Folders("Public Folders").Folders("All Public
Folders").Folders("North America").Folders("Business functions/Projects
(Cross-site)")
Dim pfFolder = oNS.Folders("Public Folders").Folders("Favorites")
Dim chkfold = oNS.Folders("Public
Folders").Folders("Favorites").Folders("NA Field Force Automation")
If chkfold Is Nothing Then
'If chkfold Is Nothing Then
' Reference SyncObjects.
myAPF.Folders("NA Field Force Automation").AddToPFFavorites()
bSendReceiveEnded = False
oSyncs = oNS.SyncObjects
oSync = oSyncs.Item("All Accounts")
' Send and receive.
oSync.Start()
Do While bSendReceiveEnded = False
myTimer.Enabled = True
Loop
Dim favfold = oNS.Folders("Public
Folders").Folders("Favorites").Folders("NA Field Force Automation")
favfold.display()
'End If
End If
' Clean up.
chkfold = Nothing
myAPF = Nothing
oSync = Nothing
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
End Module
____________________________________________________________________
"Ken Slovak - [MVP - Outlook]" wrote:
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:75A9F220-AD77-4C1E...@microsoft.com...
"Ken Slovak - [MVP - Outlook]" wrote:
Module Module1
Public Interface SyncObjectEvents
End Interface
Public bSendReceiveEnded As Boolean
Private WithEvents instance As Outlook.SyncObject
instance = oSyncs.Item("All Accounts")
' Send and receive.
instance.Start()
'Do While bSendReceiveEnded = False
' myTimer.Enabled = True
' Loop
Dim favfold = oNS.Folders("Public
Folders").Folders("Favorites").Folders("NA Field Force Automation")
favfold.display()
'End If
Else
MessageBox.Show("chkfold IsNot Nothing")
End If
' Clean up.
chkfold = Nothing
myAPF = Nothing
'oSync = Nothing
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
End Module
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:25931AB9-0314-4AE9...@microsoft.com...
"Ken Slovak - [MVP - Outlook]" wrote:
If you do use something like a loop I'd put a DoEvents in the loop so you
cede control to other processes while the loop is running.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:6A8FDDBD-0C77-4AA9...@microsoft.com...
"Ken Slovak - [MVP - Outlook]" wrote:
An alternative might be to use a form that has a Close button and showing
that form modally would prevent the app from completing.
This isn't a VB thing, the same thing would happen using VB6 or C# or Delphi
or C++ or whatever in standalone code. You have to find a way to prevent the
code from completing and shutting down a standalone app. It's the same with
any event driven application.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Jaswicki" <Jasw...@discussions.microsoft.com> wrote in message
news:31528D67-3B5C-473B...@microsoft.com...
"Ken Slovak - [MVP - Outlook]" wrote:
I face the same problem than Jaswicki. I used the code, I tryed it in many
configuration, I have never gotten any sycn event fired (neither start, end
or progress).
Here is a standalone code that should work according to your discussion. Any
clue?
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Public Interface SyncObjectEvents
End Interface
Public bSendReceiveEnded As Boolean
Private WithEvents instance As Outlook.SyncObject
Sub instance_SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub
Sub Main()
On Error Resume Next
' Create an Outlook application.
Dim oApp As Outlook._Application = New Outlook.Application
' Create the name space.
Dim oNS As Outlook._NameSpace = oApp.GetNamespace("mapi")
Dim oSyncs As Outlook.SyncObjects
bSendReceiveEnded = False
oSyncs = oNS.SyncObjects
instance = oSyncs.Item(3)
' Send and receive.
instance.Start()
Do While bSendReceiveEnded = False
System.Windows.Forms.Application.DoEvents()
Loop
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
End Module
I added to the project references to the .COM 'Microsoft Outlook 11.0 Object
Library' and to .NET system.windows.forms
I am compiling with VB 2005 express edition and using Outlook 2003
I have been searching around without any clue... So thanks for any help