null reference exception accessing appointments subject

Add-in Express™ Support Service
That's what is more important than anything else

null reference exception accessing appointments subject
 
nfsadx




Posts: 56
Joined: 2006-07-21
I have a bizarre problem. I have the following pseudocode behind the click event of a button on an ADX for OL form:


1) x = Appointment.Start;
2) y = Appointment.End;
3) z = Appointment.Subject


for a new appointment with a subject, i get a null reference exception executing line 3.
No exception is thrown for an existing appointment.

Anybody got any ideas?

Posted 02 Aug, 2006 07:35:46 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Harry, try to save an appointment before you call the Subject property.
E.g.

Appointment.Save();
......
z = Appointment.Subject

Posted 02 Aug, 2006 18:40:06 Top
nfsadx




Posts: 56
Joined: 2006-07-21
Hi Sergey,

any ideas why I can call the Start and End properties without saving but to access the subject, i must save it first?

Also, if i do Appointment.Save, what if the user subsequently cancels the save when they close the item?
Posted 04 Aug, 2006 04:42:21 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi Harry.

What version of Outlook do you use?

Also, if i do Appointment.Save, what if the user subsequently cancels the save when they close the item?

In this case you should develop the code that removes the item.
Posted 04 Aug, 2006 18:06:38 Top
nfsadx




Posts: 56
Joined: 2006-07-21
Hi Sergey,

OL2003 SP1 on winXP

any ideas why I can call the Start and End properties without saving the item but to access the subject, i must save it first? Are there any other fields that behave this way?
Posted 07 Aug, 2006 03:33:53 Top
Sergey Grischenko


Add-in Express team


Posts: 7225
Joined: 2004-07-05
Hi Harry.

I tested this situation in Outlook 2003 SP2. It worked fine.
I got the empty subject without saving it. Try to install the SP2 for Office 2003.
Posted 07 Aug, 2006 17:59:25 Top
Matt Driver


Matt


Posts: 152
Joined: 2004-08-17
Hi

I have found many fields that behave like the above in the Outlook Object Model. Do you use Outlook Spy - http://www.dimastr.com/outspy/ its a excellent toolbar not expensive either. It allows you to view all the raw properties of the items in exchange. So you can create an Appointment click on a button in the toolbar and see all its properties you will see which fields have not been written back to the database until you hit save as above example.

This way you can handle in your code

try{
get field xxxx
}
catch
{
must be null as its not been saved
}

and avoid the exceptions to the client and write code around it.

Matt
Posted 08 Aug, 2006 07:33:40 Top