how to get the Appointment End property

  • Thread starter Thread starter soworl
  • Start date Start date
S

soworl

Hello,

I don't know how I can get the "End" property of Appointment.

Please, advise me.

Thanks,
soworl
=================================================
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;
string EndTime= objItem.GetType().InvokeMember("End",
System.Reflection.BindingFlags.GetProperty, null, objItem, null) as string;
ReminderObject.Dismiss();
objItem = null;
}
#endregion
=================================================
 
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;

object[] args = new object[] { };
Type t = objItem.GetType();

string EndTime = (string)t.InvokeMember("End",
BindingFlags.Public |
BindingFlags.GetField |
BindingFlags.GetProperty,
null,
objItem,
args);

ReminderObject.Dismiss();
objItem = null;
}
#endregion

I'd stick all that in a try{}...catch{} block though.
 
Hi,

Thanks for quick reply.
I had same problem before.

If I use below code, Dismiss() dose not work.
without below code, Dismiss() works fine T.T
Is there any other way to get End time?


string EndTime = (string)t.InvokeMember("End",
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.GetField |
System.Reflection.BindingFlags.GetProperty,
null,
objItem,
args);


Ken Slovak - said:
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;

object[] args = new object[] { };
Type t = objItem.GetType();

string EndTime = (string)t.InvokeMember("End",
BindingFlags.Public |
BindingFlags.GetField |
BindingFlags.GetProperty,
null,
objItem,
args);

ReminderObject.Dismiss();
objItem = null;
}
#endregion

I'd stick all that in a try{}...catch{} block though.




soworl said:
Hello,

I don't know how I can get the "End" property of Appointment.

Please, advise me.

Thanks,
soworl
=================================================
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;
string EndTime= objItem.GetType().InvokeMember("End",
System.Reflection.BindingFlags.GetProperty, null, objItem, null) as
string;
ReminderObject.Dismiss();
objItem = null;
}
#endregion
=================================================
 
so strange,

it's ok with Subject property.
If I use below code instead of End Property, Dismiss() works fine.


string subject = (string)t.InvokeMember("Subject",

System.Reflection.BindingFlags.Public |

System.Reflection.BindingFlags.GetField |

System.Reflection.BindingFlags.GetProperty,
null,
objItem,
args);


soworl said:
Hi,

Thanks for quick reply.
I had same problem before.

If I use below code, Dismiss() dose not work.
without below code, Dismiss() works fine T.T
Is there any other way to get End time?


string EndTime = (string)t.InvokeMember("End",
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.GetField |
System.Reflection.BindingFlags.GetProperty,
null,
objItem,
args);


Ken Slovak - said:
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;

object[] args = new object[] { };
Type t = objItem.GetType();

string EndTime = (string)t.InvokeMember("End",
BindingFlags.Public |
BindingFlags.GetField |
BindingFlags.GetProperty,
null,
objItem,
args);

ReminderObject.Dismiss();
objItem = null;
}
#endregion

I'd stick all that in a try{}...catch{} block though.




soworl said:
Hello,

I don't know how I can get the "End" property of Appointment.

Please, advise me.

Thanks,
soworl
=================================================
#region event handlers
private void Reminders_ReminderFire(Outlook.Reminder ReminderObject)
{
object objItem;
objItem = ReminderObject.Item;
string EndTime= objItem.GetType().InvokeMember("End",
System.Reflection.BindingFlags.GetProperty, null, objItem, null) as
string;
ReminderObject.Dismiss();
objItem = null;
}
#endregion
=================================================
 
That probably means you're not getting an AppointmentItem and probably
should be wrapping the reflection call in a try...catch block like I said
before.

Why not just cast the item to an AppointmentItem if it is one and use early
binding directly? You can test the Class property, which every Outlook item
has:

if (objItem = ReminderObject.Item.Class ==
Outlook.OlObjectClass.olAppointment)
{
// it's an appointment, continue
}
else
{
// if there's something you do for non-appointments
}
 
Back
Top