473,394 Members | 1,813 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,394 software developers and data experts.

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(index)??

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 = (AppointmentItem) items[i];

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

Nov 17 '05 #1
1 4261
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*********@san.rr.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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(index)??

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 = (AppointmentItem) 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
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...
3
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...
1
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...
0
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...
1
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...
6
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...
0
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...
13
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...
3
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...
4
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:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...
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...

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.