Problems with MySQL and Outlook

W

win

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!
 
W

win

Thanks for your reply.

This code is used to listen to the messages sent:
private void frmMail_Load(object sender, EventArgs e)
{
Outlook.Application outLookApp = new Outlook.ApplicationClass
();
outLookApp.ItemSend += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler
(Application_SendItem);
}

When sending the email, I Have the message: "Send Item".
void Application_SendItem(object Item, ref bool Cancel)
{
MessageBox.Show("Send Item");
//Registration message code
}
After I register for the message: Registration message code (file or
Mysql).

If I do not open MySQL connections, when sending messages -->I have
always detect: Send Item.

If I open MySQL connections, when sending messages --> the message
sent is not detected.
private void frmMail_Load(object sender, EventArgs e)
{
MySqlConnection myConn;
myConn = new MySqlConnection
("Server=server;Database=db;Uid=uid;Pwd=pw;");
myConn.Open();
Outlook.Application outLookApp = new
Outlook.ApplicationClass();
outLookApp.ItemSend += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler
(Application_SendItem);
}

The code is not executed:
void Application_SendItem(object Item, ref bool Cancel)
{
MessageBox.Show("Send Item");
//Registration message code
}


Could be a conflict between MySQL and Outlook?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top