473,804 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ApplicationEven ts_11_NewMailEx EventHandler 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.NewMail Ex += new
ApplicationEven ts_11_NewMailEx EventHandler(ou tlook_NewMailEx );
}
........
private static void outlook_NewMail Ex(string EntryIDCollecti on)
{
Console.WriteLi ne("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 3080
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.NewMail Ex += new
ApplicationEven ts_11_NewMailEx EventHandler(ou tlook_NewMailEx );
Console.ReadLin e(); //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******** *************@j 55g2000cwa.goog legroups.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.NewMail Ex += new
ApplicationEven ts_11_NewMailEx EventHandler(ou tlook_NewMailEx );
}
.......
private static void outlook_NewMail Ex(string EntryIDCollecti on)
{
Console.WriteLi ne("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
371
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 SelectedIndexChanged DataSourceChanged SelectedIndexChanged is there any way to check in SelectedIndexChanged event handler that
8
11602
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 be updated when a group of items is copied. I can successfully do this with cursors, but am experimenting with a way to do it with a single update statement. I have verified that each row being returned to the Update statement (in an...
3
2552
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 on individual product names. I am getting data by calling the same stored procedure multiple times... for the single set of data I use "product like '%'" To get the data for individual products, I am using a cursor to parse
32
14917
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
6
5002
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 for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
22
8942
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 utilities.dll just once? Thanks, Brett
0
1003
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 outlook = new Application(); outlook.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outlook_NewMailEx);
5
6997
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 to complain about nulls and then about 'can't repeat an index'. To solve this I wrote code on the main form's subform enter event (I'm surprised I found it. I must have spent an hour trying to program the enter and exit events from the subform...
2
9695
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 event fires twice: List<Trailertrailers = Trailer.SelectAll();
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.