This group is for custom Outlook forms questions.
Is this code running in a standalone program or in an Outlook addin?
Where are you declaring the Application object and adding the event handler,
is it at a scope where it won't get garbage collected?
Are there any exceptions?
Does it help if you declare your Connection object at a class scope and not
each time the event fires? Just opening and closing the Connection in the
event handler?
"win" <wintelreport@gmail.com> wrote in message
news:285a78ac-7fee-404c-a0d1-e03c147f5797@22g2000yqr.googlegroups.com...
> Send mail on event
>
> Outlook.Application outLookApp = new Outlook.ApplicationClass();
> outLookApp.ItemSend += new
> Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler
> (Application_SendItem);
>
> But if I write the event into a file, all ok.
>
> void Application_SendItem(object Item, ref bool Cancel)
> {
> MessageBox.Show("Send Item");
> StreamWriter writer = new StreamWriter("C:\\Log.txt");
> writer.WriteLine("Send Item");
> writer.Close();
> }
>
> If I connect with mysql db. Event is raised only the first time!
>
> void Application_SendItem(object Item, ref bool Cancel)
> {
> MySqlConnection myConn;
> myConn = new MySqlConnection
> ("Server=localhost;Database=db;Uid=uid;Pwd=pw;");
> myConn.Open();
> myConn.Close();
> }
> After my program does not detect events outlook!
>
> You know why?
>
> Windows Xp
> Mysql : 5
> Microsoft Outlook 2003
> C#
>
>
> Thanks!