none
[VS 2010 - Outlook 2007] Calendar delay and calendar appointments UID RRS feed

  • Question

  • Greetings to you who reads it.

    I have managed to connect to outlook and create an appointment in the calendar using visual studio 2010. But when I do create an appointment always takes time before I see it in the outlook 2007 calendar (never timed it but think about 5-10 minutes). Is there a way to refresh outlook so that it shows up more quickly?

    Also I haven't been able to find out is how to set the UID of the appointment , and if that is not posible how to retrieve the UID of the appointment that was just created? Or does VB use a different way to find and edit the appointment?

    Thanks in advance.

    • Moved by Carl Cai Tuesday, September 30, 2014 6:16 AM (from vb.net)more related
    Monday, September 29, 2014 10:19 AM

Answers

  • Hello,

    You need to call the Save method to get the properties filled. For example, such properties as EntryID are set only when the item is saved. New items don't have such properties set.

    There is no need to kill Outlook processes and run it anew. Instead, you can use the GetActiveObject  method of the System.Runtime.InteropServices.Marshal class. It obtains a running instance of the specified object from the running object table (ROT).

    Function GetApplicationObject() As Outlook.Application
                Dim application As Outlook.Application
                ' Check whether there is an Outlook process running.
                If Process.GetProcessesByName("OUTLOOK").Count() > 0 Then
                    ' If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                    application = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
                Else
                    ' If not, create a new instance of Outlook and log on to the default profile.
                    application = New Outlook.Application()
                    Dim ns As Outlook.NameSpace = application.GetNamespace("MAPI")
                    ns.Logon("", "", Missing.Value, Missing.Value)
                    ns = Nothing
                End If
    
                ' Return the Outlook Application object.
                Return application
    End Function

    See How to: Get and Log On to an Instance of Outlook for more information.


    Wednesday, October 1, 2014 4:04 PM

All replies

  • Hello,

    Since this issue is mainly related to Outlook development, I have helped you move this thread to Outlook for developers forum to get dedicated supports.

    Thanks for your understanding.

    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.

    Tuesday, September 30, 2014 6:18 AM
  • What is your code that creates the appointment?

    To read the UID of an appointment, use the AppointmentItem.GlobalAppointmentID property. The property is read only, so you cannot set it using the Outlook Object Model. Newer version of Outlook however set that property immediately after the appointment is created. Why do you need to set it?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, September 30, 2014 6:28 AM
  • Hello S_Dijk,

    >  Is there a way to refresh outlook so that it shows up more quickly?

    First of all, make sure that you release underlying COM objects instantly. If develop .Net based solution, use System.Runtime.InteropServices.Marshal.ReleaseComObject to release an Outlook object when you have finished using it. Then set a variable to Nothing in Visual Basic (null in C#) to release the reference to the object. You can read more about this in the Systematically Releasing Objects article.

    Also you can try to switch to another folder programmatically and then return back to see the changes immediately. The CurrentFolder property of the Explorer class can use for this. It allows to set a Folder object that represents the current folder displayed in the explorer.

    > how to retrieve the UID of the appointment that was just created?

    See the GlobalAppointmentID property of the AppointmentItem class. It returns a string value that represents a unique global identifier for the AppointmentItem object.

    Tuesday, September 30, 2014 10:13 AM
  • Sorry for the late reply back (important other small project had to be done) and thank for your responce and thanks for placing it in the right forum (also sorry about that). Going to try everything this week hopefully but didn't want to seem ungrateful by not replying. *S_Dijk bows in respect*

    The idea behind the main part of the program: this company helps people with problems with things like living on your own, helping people raising children, helping people in work environment, ect. Now they created a roster design for the people (think it is called counselors in english). That roster is like code 1: go to client1 at 9:00, client2 at 10:00, client3 at 11:00. Code 2: client4 at 14:00 client1 (yes again) 15:00, client5 at 16:00, ect ect. And each day is has different codes and each month (even sometimes more) the codes changes because the client can't be visited at that time anymore, or because they need more/less guidance or because of new clients. But the clients also need a list so that they know when to except someone, who to expect and in case of trouble outside of normal work hours who to call that day.

    Since it took a lot of time to do this manually I started to see if I could create a program that when entered to codes into it that it could create the client rosters automatically. This all works as it should. Now the idea was instead of paper maybe try to link it to an online calendar (since a lot of clients lose the paper apparently).

    They counselors already wanted to a online calendars (with specific wishes, also for the future). They wanted every calendar linked with each other, every counselors should be able see every roster of each other and of the clients (when this is online) but only a few people should be able to change/add appointments for others while other counselors can only change/add to their own calendars or just a few other people (like interns calendars). The clients should only be able to see their own appointments but shouldn't be allowed to change anything. What I found was the calendars of the website zoho which seems to be able to do what we want but their plugin for outlook is only for outlook 2007 (2010 is still in beta (already been in development for 3 years from what I have seen on their forum) so if you know a better solutions for this I am all ears but that's not really the question here).

    As for the questions why do I want to set the UID. I had the idea in my head that I would create my own UID (yes zoho supports that) and create it like Clientname-date-appointment(1, 2 or 3) so that I could find it easy when it needs to be changed again. But I guess I can create an internal UID like that and link the calendar UID to it.

    Quote>Newer version of Outlook however set that property immediately after the appointment is created</Quote> Since I need 2007 can I see use AppointmentItem.GlobalAppointmentID to see it immediately or is there something else I need to do. I am using vb.net. C# is still way to hard for this newby programmer.

    P.S. The code I am using. The killing of outlook was a test to see if I could get it to update faster

    At the top: Imports Microsoft.Office.Interop

    Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Outlook")
            For Each p As Process In pProcess
                p.Kill()
            Next
            Dim Outlookapp As Outlook.Application
            Outlookapp = New Outlook.Application
            Dim outlookevent As Outlook.AppointmentItem = Nothing
            outlookevent = Outlookapp.CreateItem(Outlook.OlItemType.olAppointmentItem)
            outlookevent.Start = Date.Now
            outlookevent.End = Date.Now.AddHours(2)
            outlookevent.Subject = "Test123"
            outlookevent.Body = "456test"
            outlookevent.Save()
            Marshal.ReleaseComObject(outlookevent)
            System.Diagnostics.Process.Start("C:\Program Files (x86)\Microsoft Office\Office12\OUTLOOK.EXE")
            Outlookapp.Application.Quit()
            For Each p As Process In pProcess
                p.Kill()
            Next

    Wednesday, October 1, 2014 2:43 PM
  • Hello,

    You need to call the Save method to get the properties filled. For example, such properties as EntryID are set only when the item is saved. New items don't have such properties set.

    There is no need to kill Outlook processes and run it anew. Instead, you can use the GetActiveObject  method of the System.Runtime.InteropServices.Marshal class. It obtains a running instance of the specified object from the running object table (ROT).

    Function GetApplicationObject() As Outlook.Application
                Dim application As Outlook.Application
                ' Check whether there is an Outlook process running.
                If Process.GetProcessesByName("OUTLOOK").Count() > 0 Then
                    ' If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                    application = DirectCast(Marshal.GetActiveObject("Outlook.Application"), Outlook.Application)
                Else
                    ' If not, create a new instance of Outlook and log on to the default profile.
                    application = New Outlook.Application()
                    Dim ns As Outlook.NameSpace = application.GetNamespace("MAPI")
                    ns.Logon("", "", Missing.Value, Missing.Value)
                    ns = Nothing
                End If
    
                ' Return the Outlook Application object.
                Return application
    End Function

    See How to: Get and Log On to an Instance of Outlook for more information.


    Wednesday, October 1, 2014 4:04 PM