473,769 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception Removing/Deleting Appointment??


Windows XP SP2
C# .NET v1.1
Outlook 2003 {via Office 11.0 PIA}

I'm manipulating Outlook's calendar via OLE automation from my C#
application. I would like to iterate through the calendar items
collection and delete appointments from the items collection based on
some business rules. However after I delete/remove items I am getting
"index out of range" and/or "object has been moved or deleted" errors.
Also, sometimes it seems that the item collection's Count property does
not acknowledge that I have deleted something during a loop iteration -
has anybody seen this behavior?

Question: What is the correct & proper way to delete a calendar item
while iterating the items collection? Is it AppointmentItem .Delete()
or is it Items.Remove(in dex)??

Pseudo code, note that I don't use a foreach loop because I need to
modify the collection:

int i = 1;
while (i <= items.Count)
{
AppointmentItem ai = (AppointmentIte m) items[i];

if (<<my business rules>>)
{
ai.Delete(); // --> or items.Remove(i) ????
}
else
{
<<my other action>>
++i;
}
}

Nov 17 '05 #1
1 4289
Use a down counting loop or a Do loop that tests for any items still
remaining.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Crash" <so*********@sa n.rr.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .

Windows XP SP2
C# .NET v1.1
Outlook 2003 {via Office 11.0 PIA}

I'm manipulating Outlook's calendar via OLE automation from my C#
application. I would like to iterate through the calendar items
collection and delete appointments from the items collection based on
some business rules. However after I delete/remove items I am getting
"index out of range" and/or "object has been moved or deleted" errors.
Also, sometimes it seems that the item collection's Count property does
not acknowledge that I have deleted something during a loop iteration -
has anybody seen this behavior?

Question: What is the correct & proper way to delete a calendar item
while iterating the items collection? Is it AppointmentItem .Delete()
or is it Items.Remove(in dex)??

Pseudo code, note that I don't use a foreach loop because I need to
modify the collection:

int i = 1;
while (i <= items.Count)
{
AppointmentItem ai = (AppointmentIte m) items[i];

if (<<my business rules>>)
{
ai.Delete(); // --> or items.Remove(i) ????
}
else
{
<<my other action>>
++i;
}
}


Nov 17 '05 #2

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

Similar topics

0
4012
by: Matt Moran | last post by:
I need/want to be able to send an email from a website running IIS and CDONTS for mail (or ASPMAIL) that comes into the inbox as an appointment to be accepted. The company is not running Exchange internally or on the website (which is hosted). Here is the basic app: A visitor schedules an appointment to speak to a rep from the company. Their appointment data is kept in a SQL DB.
3
7519
by: Sam | last post by:
My db looks after the hiring and lending of equipment, the form which books out equipment hired prints a signout sheet and automatically inserts an appointment into outlook advising the operator on the due date that a particular hire is due. I have used microsoft's automated appointment code to do this, what I would also like the code to do is to email an appointment to the person hiring the gear. Knowing that you can email an...
1
4783
by: THDWWSIJQUOK | last post by:
I have (or should I say "had") a module which I invested quite a few hours of work into. I was poking around trying to rename the module and instead wound up removing the darn thing. It's been a long time since I've lost any work because I normally make backups and have the experience not to make stupid mistakes like this. I'm still shocked how quickly it happened... I noticed the module was called "module1" so I went to give it a
0
2859
by: saurabhaggarwal | last post by:
Hi Suppose there is backend that stores all the appointments that are currently there in outlook. The job of my plugin is to add all the appointments that are there in outlook back to the database and if there is any appointment in database but not in outlook then plugin adds that appointment to the outlook.
1
2519
by: jodyblau | last post by:
I am using the code provided by MSDN to set an appointment on my Outlook. However, I would like to adjust this code so that instead of setting the appointment on in Outlook on my computer, it places it in Outlook on a different computer on the network. Here is the code sample from MSDN; any suggestions on how I might accomplish my goal? Private Sub cmdAddAppt_Click() On Error GoTo Add_Err 'Save record first to be sure required fields...
6
6114
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or more minutes. 'REMOVE DUBLICATED VALUE FROM ARRAY +++++++++++++++++ Dim col As New Scripting.Dictionary Dim ii As Integer = 0
0
1791
by: Chicka | last post by:
I need/want to be able to send an email from a website running IIS and CDONTS for mail (or ASPMAIL) that comes into the inbox as an appointment to be accepted. The company is not running Exchange internally or on the website (which is hosted). Here is the basic app: A visitor schedules an appointment to speak to a rep from the company. Their appointment data is kept in a SQL DB.
13
9971
by: YoVoltron | last post by:
I am just starting this "appointment book" java program and would appreciate some basis direction. I do not expect anyone to write the code for me but i would like opinions on how to best handle the situation. Specifically should i use <arraylist> or a hashtable or is these a better way? Thank you all in advance. here is the assignment... sorry if it is too long. In this assignment you will demonstrate your understanding of designing with...
3
1328
by: geo039 | last post by:
I have a simple application that takes user input by text and time selected by date time picker. It displays the appt description in one list box and the time in another list box. I need a simple function that checks the times for duplicates. I want to check for a duplicate before it writes to the listbox by returning a boolean (true/false) value. I only need to check hours and minutes not date or seconds. I'm new to this so any help would...
4
3254
by: =?Utf-8?B?U0g=?= | last post by:
There seems to be an issue with .NET 3.5/Visual Studio 2008 (Team System). After convincing my company to create our latest project in .NET 3.5, this is kind of reflecting bad on me. Problem: Solution will NOT compile. Error is simply: "External component has thrown an exception". NO other details.
0
9589
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
9423
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
9865
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
8873
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...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
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();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.