none
Outlook Appointments - Filter by Categorie - For Each / Case --> Outlook.items / Outlook.appointmentItems RRS feed

  • Question

  • Hello Together, 

    i m facing a problem, with the assignment of an appointment to the items. 

    if i found a hit, i want of couse to save it somewhere, to use it later as a " Microsoft.Office.Interop.Outlook.Items - Objekt"

        Public objTermin As Microsoft.Office.Interop.Outlook.AppointmentItem
        Public objTerminGruppe As Microsoft.Office.Interop.Outlook.Items
        Public objTerminGruppe2 As Microsoft.Office.Interop.Outlook.Items

     For Each objTermin1 In objTerminGruppe

    Select Case objTermin1.Categories

    Case vcbUrlaub

    ' Here is the Problem, i m not able to save my founded appointment'

    ' item and add it to the item-list :('

    objTerminGruppe2 = objTerminGruppe2.Application.CreateItem(objTermin1) MsgBox(objTerminGruppe2.Item(1).ToString) Case vcbKrank objTerminGruppe2.Add(objTerminGruppe.Item(objTermin1)) End Select

      Next

    Do anybody have a hint ?







    • Edited by Gentlemanlike Friday, January 16, 2015 1:40 PM
    • Moved by Carl Cai Monday, January 19, 2015 2:15 AM more related
    Friday, January 16, 2015 1:34 PM

Answers

  • Hi,

    You could use is keyword to check the dynamic object type.

    For example:

    dynamic dp = newAppointment;
    if(dp is Outlook.AppointmentItem)
    {
      //TODO
    }

    On the other hand, based on your original code, you are using Items.Add method, this method is used to create a new item instead of get exist item.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, January 26, 2015 6:24 AM
    Moderator

All replies

  • Hello,

    Even though this is VB.NET I would suggest allowing me to move your question to a dedicated Outlook for developer forum here. Let me know if you would like to have this question moved.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Friday, January 16, 2015 2:57 PM
  • Hello,

    Since this issue is mainly related to getting that task done by outlook object module, and I found that you voted Kevin's reply which seems that you agree with his suggestion, I will help you move this thread to Outlook for Developers forum to get support.

    Regards,

    Carl


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, January 19, 2015 2:15 AM
  • Hello Gentleman,

    Outlook uses EntryIDs for identifying their items.

    You can use EntryID for storing anywhere in your application. Then, when you need to get an instance of the AppointmentItrem class, you can use the GetItemFromId method of the Namespace class.

    Monday, January 19, 2015 6:16 AM
  • i tried now serval ways to get this job done. but till now always the same kind of issues. 

    either i get en error that no interface is supported, object is not refer to an instance or that i have a typ conflict. 

    seems to be a hard nut. 

    here are the ways, but nothing worked, is there no known way to sign an appointmentitem to the typ of items ?

    Public objTermin As Microsoft.Office.Interop.Outlook.AppointmentItem
        Public objTerminGruppe As Microsoft.Office.Interop.Outlook.Items
        Public objTerminGruppe2 As Microsoft.Office.Interop.Outlook.Items
    Dim interv As Microsoft.Office.Interop.Outlook._Items
    
    
    
    objTerminGruppe.Item(i).move(objTerminGruppe2.Parent)
    
    objTerminGruppe.Item(i).move(objTerminGruppe2)
    
    interv = objTerminGruppe.Add(objTermin)
    
    objTerminGruppe2 = objTerminGruppe.Item(i)
    
    objTerminGruppe2 = objTerminGruppe.Item(i).copy


    Tuesday, January 20, 2015 8:36 PM
  • Hi,

    First, do you try the solution that Eugene provided that store the EntryID anywhere, then base on the EntryID to get specific item object?

    For example:

    Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
     newAppointment.Subject = "sub2";
                    newAppointment.Body = "body2";
    newAppointment.Save();
     string s = newAppointment.EntryID;
     Outlook.NameSpace ns=this.Application.GetNamespace("MAPI");
                    Outlook.AppointmentItem oldAppointment = ns.GetItemFromID(s) as Outlook.AppointmentItem;
    
    string subject=oldAppointment.Subject;

    Secondly, if you want to store the specific item object directly, you could use dynamic type.

    For example:

     Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)this.Application.CreateItem(Outlook.OlItemType.olAppointmentItem);
                    newAppointment.Start = DateTime.Now.AddMinutes(3);
                    newAppointment.End = DateTime.Now.AddDays(1).AddMinutes(2);
                    newAppointment.Subject = "sub2";
                    newAppointment.Body = "body2";
    dynamic dp = newAppointment;
     Outlook.AppointmentItem oldAppointment = dp as Outlook.AppointmentItem;
    string subject=oldAppintment.Subject;

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 23, 2015 3:42 AM
    Moderator
  • @Chen thank you i tired it, with the entry id. and to create a new one i think is possible. 

    i have the problem, that i have a collection of items which could be anything ( Contacts, emails etc.. ) in my case these are appointments. 

    and now i want to build a loop to read the categorie of these appointments afterwards, i want to save somehow the hits of the categorie in the loop, into another collection (outlook.items object) 

    and here is the mistake, i dont get this job done. 

    so iterate through special appointment categories is the use case. 

    Friday, January 23, 2015 6:48 PM
  • You can use Type.InvokeMember method for accessing class members dynamically. For example, if you don't want to check out underlying type of the object and want to get a property value - you can simply use Reflection. Does it make sense?
    Friday, January 23, 2015 7:39 PM
  • Hi,

    You could use is keyword to check the dynamic object type.

    For example:

    dynamic dp = newAppointment;
    if(dp is Outlook.AppointmentItem)
    {
      //TODO
    }

    On the other hand, based on your original code, you are using Items.Add method, this method is used to create a new item instead of get exist item.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, January 26, 2015 6:24 AM
    Moderator