G
Guest
I am doing a Add-In for OUTLOOK by C Sharp, but i am getting trouble with a
quite weird problem.
actually, i wish to save the mail details when one mail sent.. but when i
make use of the save methods, which just execute once. Therefore, i use
messageBox to test it. It is quite amazing that sometimes it just execute
twice(Testing CASE1, see following code), sometimes it run three
times(Testing CASE2). However, if i just use messageBox, do not make use of
any other functions and methods, it's right..
I do not where is wrong??? and how to solve it???? I really need your help,
due to this is my final year project, which is so crucial for me!!! MANY
THANKS!!!
I really appreciate any help if anyone give to me....
ROBIN
the following are my codes:
public void OnStartupComplete(ref System.Array custom)
{
sentFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
sentFolder.Items.ItemAdd +=new
ItemsEvents_ItemAddEventHandler(sentFolder_ItemAdd);
}
private void sentFolder_ItemAdd(object Ctrl)
{
MessageBox.Show("Sent Folder Testing1");
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Ctrl;
MessageBox.Show("Sent Folder Testing2");
// Testing CASE1: which just execute twice to disply the testing messages,
in the third time, there is nothing to show
/*
mail_table.Add(mailItem, mailItem);
IDictionaryEnumerator enumerator = mail_table.GetEnumerator();
while(enumerator.MoveNext())
{
Microsoft.Office.Interop.Outlook.MailItem item =
(Microsoft.Office.Interop.Outlook.MailItem) enumerator.Key;
MessageBox.Show(item.SentOn.ToString()+ item.Recipients.Count.ToString() +
item.Subject);
}
*/
//Testing CASE2: the following execute three times to disply the testing
message, there is nothing to show in the fourth time.
//MessageBox.Show(mailItem.SentOn.ToString() + mailItem.Subject);
//MessageBox.Show("Sent Folder Testing3");
}
quite weird problem.
actually, i wish to save the mail details when one mail sent.. but when i
make use of the save methods, which just execute once. Therefore, i use
messageBox to test it. It is quite amazing that sometimes it just execute
twice(Testing CASE1, see following code), sometimes it run three
times(Testing CASE2). However, if i just use messageBox, do not make use of
any other functions and methods, it's right..
I do not where is wrong??? and how to solve it???? I really need your help,
due to this is my final year project, which is so crucial for me!!! MANY
THANKS!!!
I really appreciate any help if anyone give to me....
ROBIN
the following are my codes:
public void OnStartupComplete(ref System.Array custom)
{
sentFolder = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
sentFolder.Items.ItemAdd +=new
ItemsEvents_ItemAddEventHandler(sentFolder_ItemAdd);
}
private void sentFolder_ItemAdd(object Ctrl)
{
MessageBox.Show("Sent Folder Testing1");
Microsoft.Office.Interop.Outlook.MailItem mailItem =
(Microsoft.Office.Interop.Outlook.MailItem) Ctrl;
MessageBox.Show("Sent Folder Testing2");
// Testing CASE1: which just execute twice to disply the testing messages,
in the third time, there is nothing to show
/*
mail_table.Add(mailItem, mailItem);
IDictionaryEnumerator enumerator = mail_table.GetEnumerator();
while(enumerator.MoveNext())
{
Microsoft.Office.Interop.Outlook.MailItem item =
(Microsoft.Office.Interop.Outlook.MailItem) enumerator.Key;
MessageBox.Show(item.SentOn.ToString()+ item.Recipients.Count.ToString() +
item.Subject);
}
*/
//Testing CASE2: the following execute three times to disply the testing
message, there is nothing to show in the fourth time.
//MessageBox.Show(mailItem.SentOn.ToString() + mailItem.Subject);
//MessageBox.Show("Sent Folder Testing3");
}