473,396 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

ApplicationEvents_11_NewMailExEventHandler fires multiple times for a single email

I have a simple test app that I have written to gain some knowledge
about the API for accessing Outlook using Visual Studio .NET

Relevant snippets are
........
while(true)
{
Application outlook = new Application();
outlook.NewMailEx += new
ApplicationEvents_11_NewMailExEventHandler(outlook _NewMailEx);
}
........
private static void outlook_NewMailEx(string EntryIDCollection)
{
Console.WriteLine("New mail arrived .... !");
}
I realise that there may be a problem with the "while(true)" part
(otherwise it simply exits when the process starts) but I was expecting

that when I send the test email, I should see only one line at the
console saying "New mail arrived ....!". Instead I see thousands !!

Any help is appreciated,
- K

May 24 '06 #1
2 3068
What are you doing is subscribing to the event infinite number of times.
What you probably want to do is:

(i assume you have a console application)

Application outlook = new Application();
outlook.NewMailEx += new
ApplicationEvents_11_NewMailExEventHandler(outlook _NewMailEx);
Console.ReadLine(); //this stops the current thread until you press enter in
the console

if you have winform application, just subscribe to the event in the
Form.Load event - and do it once J

"Paddy" <pa***************@gmail.com> wrote in message
news:11*********************@j55g2000cwa.googlegro ups.com...
I have a simple test app that I have written to gain some knowledge
about the API for accessing Outlook using Visual Studio .NET

Relevant snippets are
.......
while(true)
{
Application outlook = new Application();
outlook.NewMailEx += new
ApplicationEvents_11_NewMailExEventHandler(outlook _NewMailEx);
}
.......
private static void outlook_NewMailEx(string EntryIDCollection)
{
Console.WriteLine("New mail arrived .... !");
}
I realise that there may be a problem with the "while(true)" part
(otherwise it simply exits when the process starts) but I was expecting

that when I send the test email, I should see only one line at the
console saying "New mail arrived ....!". Instead I see thousands !!

Any help is appreciated,
- K

May 24 '06 #2
I solved it by creating a new thread and calling the delegate on it
..... But dang it, your solution is much more simpler !
Thanks,
- K

May 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TF | last post by:
hi, i am using a ListBox control on a windows form using VB.Net. when i set the DataSource property of the control to an ArrayList it fires following events in this order: SelectedIndexChanged...
8
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
3
by: wxbuff | last post by:
I have a report based on our product names that consists of two parts. Both insert data into a temporary table. 1. A single grouped set of results based on all products 2. Multiple tables based...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
22
by: Brett Romero | last post by:
If my UI app uses three DLLs and two of those DLLs reference something named utilities.dll, does the UI app load utilities.dll twice or does the compiler recognize what is going on and load...
0
by: Paddy | last post by:
I have a simple test app that I have written to gain some knowledge about the API for accessing Outlook using Visual Studio .NET Relevant snippets are ........ while(true) { Application...
5
by: christianlott1 | last post by:
I admit my form is pretty complex and may need a total overhaul - I have two subforms synchronized on a form through an unbound text box. When I enter a new record in the second subform it used...
2
by: Simon Harvey | last post by:
Hi Guys, Can anyone tell me why the DataGridView.SelectionChanged event fires twice when I databind to it. If I do the following, the first row is selected automatically, but the changed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.