(Msg. 1) Posted: Tue Aug 12, 2008 6:12 pm
Post subject: VBA or Visual Basic or VSTO for outlook sync? Archived from groups: microsoft>public>outlook>program_vba (more info?)
Hi
I have been struggling for a while with the following problem: I am trying
to write a code that will launch 'send/receive' for an Outlook account. The
purpose is to sync back outlook to an exchange server after a 1-way sync from
google mail witout opening outlook.
I have downloaded and installed visual basic 2005 express edition and could
create a console application that perform this operation. I used the
syncobect from outlook. However, the events from outlook do not fire and I
absolutely need the syncend event to wait before ending the application. I
have been intensively trying to find a bug in my code without success
So here is my question: is my code wrong or does it come from the tools I
have been using to create the application. Do I need to use VBA or the VSTO
extension to visual studio. In that case do you know if there is a free way
to do that?
Bonus question: if you have in mind another way to automatically sync
outlook to exchange, it could also be a solution!
(Msg. 2) Posted: Wed Aug 13, 2008 9:54 am
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
So what are the relevant snippets of your code?
Have you tried to create a UI app rather than a command line one?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Alban" <Alban.TakeThisOut@discussions.microsoft.com> wrote in message
news:068FEFF9-99F6-4247-BD20-E492EB1CEB52@microsoft.com...
> Hi
>
> I have been struggling for a while with the following problem: I am trying
> to write a code that will launch 'send/receive' for an Outlook account.
> The
> purpose is to sync back outlook to an exchange server after a 1-way sync
> from
> google mail witout opening outlook.
>
> I have downloaded and installed visual basic 2005 express edition and
> could
> create a console application that perform this operation. I used the
> syncobect from outlook. However, the events from outlook do not fire and I
> absolutely need the syncend event to wait before ending the application. I
> have been intensively trying to find a bug in my code without success
>
> So here is my question: is my code wrong or does it come from the tools I
> have been using to create the application. Do I need to use VBA or the
> VSTO
> extension to visual studio. In that case do you know if there is a free
> way
> to do that?
>
> Bonus question: if you have in mind another way to automatically sync
> outlook to exchange, it could also be a solution!
>
> Thanks for reading and your help
>
> Alban
(Msg. 3) Posted: Wed Aug 13, 2008 10:43 am
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Here is my code. I also linked the COM microsoft OUtlook library. I need a
console as I would like to then schedule the task without any user
interaction.
I am still confused with catching event. The more I read on the web, the
less I clarify the way events are treated in VB.NEt, VB, VBA and the role of
VSTO...
Imports Outlook = Microsoft.Office.Interop.Outlook
Module Module1
Public bSendReceiveEnded As Boolean
Public WithEvents mySync As Outlook.SyncObject
Sub mySync _SyncEnd()
MsgBox("triggered")
bSendReceiveEnded = True
End Sub
Sub Main()
' 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
(Msg. 4) Posted: Wed Aug 13, 2008 11:33 am
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I made a typo in the previous post, sorry please read
mySync .start()
instead of
instance.start()
(Msg. 5) Posted: Wed Aug 13, 2008 3:48 pm
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Does it work if you replace the DoEvents loop with a call to MessageBox()
(which also runs the message loop)?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Alban" <Alban.DeleteThis@discussions.microsoft.com> wrote in message
news:E9F463C0-E39E-48D5-807D-45FDD08635C9@microsoft.com...
> Here is my code. I also linked the COM microsoft OUtlook library. I need a
> console as I would like to then schedule the task without any user
> interaction.
>
> I am still confused with catching event. The more I read on the web, the
> less I clarify the way events are treated in VB.NEt, VB, VBA and the role
> of
> VSTO...
>
>
> Imports Outlook = Microsoft.Office.Interop.Outlook
>
> Module Module1
>
> Public bSendReceiveEnded As Boolean
> Public WithEvents mySync As Outlook.SyncObject
>
> Sub mySync _SyncEnd()
> MsgBox("triggered")
> bSendReceiveEnded = True
> End Sub
>
> Sub Main()
>
> ' 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
> mySync = 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
(Msg. 6) Posted: Wed Aug 13, 2008 4:12 pm
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
1/ I do not have such a function, am I missing a reference?
2/ what do you mean by "which also runs the message loop"?
3/ Apparently, it is not related to the loop. I have made a windows
application and launch the previous code at the click of a button. No event
is catched, whatever event I try to catch from outlook.
Note: I installed outlookspy toolbar I could see outlook event firing from
action generated by my code while my code could not see them
"Dmitry Streblechenko" wrote:
> Does it work if you replace the DoEvents loop with a call to MessageBox()
> (which also runs the message loop)?
>
> --
(Msg. 7) Posted: Thu Aug 14, 2008 12:17 am
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
What is your code that uses button click?
Is there a particular reason why you use sync object with thee index 3/ Have
you tried 1 (which in most cases is "Send/Receive All")?
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Alban" <Alban DeleteThis @discussions.microsoft.com> wrote in message
news:3F8F70B8-C23F-4DFD-AD2D-B5DC17788FD5@microsoft.com...
> 1/ I do not have such a function, am I missing a reference?
> 2/ what do you mean by "which also runs the message loop"?
> 3/ Apparently, it is not related to the loop. I have made a windows
> application and launch the previous code at the click of a button. No
> event
> is catched, whatever event I try to catch from outlook.
>
> Note: I installed outlookspy toolbar I could see outlook event firing from
> action generated by my code while my code could not see them
>
>
> "Dmitry Streblechenko" wrote:
>
>> Does it work if you replace the DoEvents loop with a call to MessageBox()
>> (which also runs the message loop)?
>>
>> --
>
(Msg. 8) Posted: Thu Aug 14, 2008 12:43 am
Post subject: Re: VBA or Visual Basic or VSTO for outlook sync? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
Thanks for your help, I hope we'll make it.
The windows application has a single form with one button nicely nammed
'button1'.
As for the accounts, I use a special account dedicated to only synchronize
the calendar from local to the server. Note that everything is the same if I
use 1. The synchronization does actually work but I Still need the events.
Code:
Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class Form1
Public bSendReceiveEnded As Boolean = False
Public WithEvents oApp As Outlook._Application
Public WithEvents mySync As Outlook._SyncObject
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
syncMail()
End Sub
Public Sub syncMail()
' Create an Outlook application.
oApp = New Outlook.Application
mySync = oApp.Session.SyncObjects.Item(3)
' Send and receive.
mySync.Start()
oSyncs = Nothing
oNS = Nothing
oApp = Nothing
End Sub
Private Sub mySync_SyncEnd()
bSendReceiveEnded = True
MsgBox("triggered")
End Sub
Private Sub mySync_SyncStart()
MsgBox("triggered")
End Sub
Private Sub mySync_OnError(ByVal Code As Long, ByVal Description As
String)
MsgBox("Unexpected sync error" & Code & ": " & Description)
End Sub
End Class
"Dmitry Streblechenko" wrote:
> What is your code that uses button click?
> Is there a particular reason why you use sync object with thee index 3/ Have
> you tried 1 (which in most cases is "Send/Receive All")?
>
> --
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/ > OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -
>
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum