none
Outlook 2010 Scheduling App - HELP RRS feed

  • Question

  • I was tasked with creating a scheduling app for assets that we use.  Each asset has an outlook calendar.  At first, I knew it was impossible bc we only had Outlook 2007.  We have since been upgraded to 2010.  I know that one person cant make an appointment and it be edited by someone else.  So I had my company create a new user (we use Microsoft Exchange server).  I had people that will be using this application to add this new user/email account to their outlook. 

    My plan was the have the application create the calendar event using this global user so that others can edit it through the app as this global user.

    So this is where I am.  A co worker put in a request for an asset.  It was added to the correct calendar with the meeting organizer as the global user I described above.  The issue I am having now is that when I go into the app to approve the request (basically just changes the color of the outlook calendar item) it doesnt work.  From what I can tell when my code tries to save the changes to the outlook appointment it is getting an error that I do not have the privileges.  So it seems like my app is not creating the event as the non default outlook user.

    each person will have their default outlook account (their company email), then they will also have this global user account.  I cant seem to create the event with this global user account.  What am i missing.

    Below is my code for creating the event and for "Approving" the event:

            Dim olApp As New Outlook.Application
            Dim olNameSpace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
            Dim olPublicFolder As Outlook.MAPIFolder
            Dim olAppt As Outlook.AppointmentItem
    
            Me.Cursor = Cursors.WaitCursor
            olApp = CreateObject("Outlook.Application")
            olNameSpace.Logon("Bench Scheduler", "", False, False)
    
            olPublicFolder = olNameSpace.Folders("Public Folders - BenchScheduler@uuu.com")
            For i As Integer = 0 To calendarpath.Length - 1
                If calendarpath(i) <> "" And calendarpath(i) <> "Public Folders" Then
                    olPublicFolder = olPublicFolder.Folders.Item(calendarpath(i))
                End If
            Next
    
            olAppt = olPublicFolder.Items.Add("IPM.Appointment")
            olAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
    
            With olAppt
                .Subject = ("Requested (ID-" & br.request_id & "): " & br.project_name & "-" & Me.typeCombobox.SelectedItem(1))
                .Location = br.bench_name
                If IsDBNull(br.setups_string) Then
                    bodytext = br.comments & vbCrLf & vbCrLf & "Bench Setups Requested:" & vbCrLf & br.setups_string.ToString
                Else
                    bodytext = br.comments
                End If
                .Body = bodytext
                .Start = CDate(br.requestdate & " " & br.start_time)
                .ReminderMinutesBeforeStart = 15
                .ReminderSet = True
                .Duration = DateDiff(DateInterval.Minute, (br.requestdate & " " & br.start_time), (br.requestdate & " " & br.end_time))
    
                For Each recip As String In br.requiredusers_email
                    .Recipients.Add(recip)
                    .Recipients(recip).Type = Outlook.OlMeetingRecipientType.olRequired
                Next
    
                For Each recip As String In br.optionalusers_email
                    .Recipients.Add(recip)
                    .Recipients(recip).Type = Outlook.OlMeetingRecipientType.olOptional
                Next
    
                .Recipients.ResolveAll()
                .Categories = "Yellow Category"
                .ResponseRequested = True
                .BusyStatus = Outlook.OlBusyStatus.olBusy
                .Save()
            End With
    
            entryid = olAppt.EntryID
            olAppt.Save()

    Approval code:

            Dim olApp As New Outlook.Application
            Dim olNameSpace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
            Dim olPublicFolder As Outlook.MAPIFolder
            Dim olAppt As Outlook.AppointmentItem
    
            olApp = CreateObject("Outlook.Application")
            olNameSpace.Logon("Bench Scheduler", "", False, False)
    
            olPublicFolder = olNameSpace.Folders("Public Folders - BenchScheduler@uuu.com")
            For i As Integer = 0 To calendarpath.Length - 1
                If calendarpath(i) <> "" And calendarpath(i) <> "Public Folders" Then
                    olPublicFolder = olPublicFolder.Folders.Item(calendarpath(i))
                End If
            Next
            On Error Resume Next
    
            Dim oItems As Outlook.Items = olPublicFolder.Items
    
            For i As Integer = 1 To oItems.Count
                'Test to make sure item is a mail item and not a meeting request.
                If InStr(oItems.Item(i).subject.ToString, "ID-" & requestid) > 0 Then
                    olAppt = oItems(i)
                    Exit For
                End If
            Next
    
            With olAppt
                .Subject = Replace(.Subject, "Requested", "Approved")
                .Categories = "Green Category"
                .Save()
                .Send()
            End With

    What am I missing?  This is killing me.  This is my last obstacle before being done with this application.  Any help would be greatly appreciated.

    Tuesday, May 7, 2013 2:46 PM

Answers

  • You need to set up a profile for whatever "user" owns that mailbox, using the mailbox as the default store for that profile. Wherever that application runs would have to log into Outlook using that profile.

    Ken Slovak MVP - Outlook

    Thursday, May 9, 2013 8:39 PM
    Moderator
  • No, that will not work. You can only have 1 Outlook session running.

    As I said earlier in the thread I don't think you can make this architecture work for what you want.

    It's just not the way Outlook works, and no matter how much you try you can't change how Outlook works.


    Ken Slovak MVP - Outlook

    Monday, May 13, 2013 2:16 PM
    Moderator
  • You can have many different stores opened in any Outlook profile and you've been able to do that for many years. Even in Outlook 2000 or earlier I usually opened my default profile with at least 4 mailboxes plus a public folders store, now I usually open my profile with 7 stores opened.

    What Outlook 2010 did was allow you to have more than 1 email account for Exchange at a time in the profile without using delegate mailboxes or using IMAP or other workaround to open the oither mailbox. But one of those mailboxes is still your defauit mailbox and store even in 2010 or 2013.

    I just don't see how what you want will work the way you want just using the Outlook object model. It could possibly work using Redemption or Extended MAPI, or EWS code maybe, but I don't see how with Outlook code.


    Ken Slovak MVP - Outlook

    Tuesday, May 14, 2013 3:18 PM
    Moderator

All replies

  • You are using both New Outlook.Application and CreateObject("Outlook.Application"), that's not a good thing to do at all. Try using only 1 Application object and session.
     
    You cannot create a meeting as another user. Your code can only create the meeting in the context of the logged in Outlook user under which the code is running. Also, meetings should be created in the current user's default Calendar folder, certainly not in a public folder, as no tracking or meeting acceptances or rejections can ever be tallied in a public folder or other folder other than the default Calendar folder.
     
    To do what you want each user would have to log into Outlook as that special user you created, not as themselves. I'm not sure the architecture of what you designed can be made to work.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "DavidKMD" <=?utf-8?B?RGF2aWRLTUQ=?=> wrote in message news:1c961599-a2b6-4ba1-bf1d-e452ab3ba90d...

    I was tasked with creating a scheduling app for assets that we use.  Each asset has an outlook calendar.  At first, I knew it was impossible bc we only had Outlook 2007.  We have since been upgraded to 2010.  I know that one person cant make an appointment and it be edited by someone else.  So I had my company create a new user (we use Microsoft Exchange server).  I had people that will be using this application to add this new user/email account to their outlook. 

    My plan was the have the application create the calendar event using this global user so that others can edit it through the app as this global user.

    So this is where I am.  A co worker put in a request for an asset.  It was added to the correct calendar with the meeting organizer as the global user I described above.  The issue I am having now is that when I go into the app to approve the request (basically just changes the color of the outlook calendar item) it doesnt work.  From what I can tell when my code tries to save the changes to the outlook appointment it is getting an error that I do not have the privileges.  So it seems like my app is not creating the event as the non default outlook user.

    each person will have their default outlook account (their company email), then they will also have this global user account.  I cant seem to create the event with this global user account.  What am i missing.

    Below is my code for creating the event and for "Approving" the event:

            Dim olApp As New Outlook.Application
            Dim olNameSpace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
            Dim olPublicFolder As Outlook.MAPIFolder
            Dim olAppt As Outlook.AppointmentItem
    
            Me.Cursor = Cursors.WaitCursor
            olApp = CreateObject("Outlook.Application")
            olNameSpace.Logon("Bench Scheduler", "", False, False)
    
            olPublicFolder = olNameSpace.Folders("Public Folders - BenchScheduler@uuu.com")
            For i As Integer = 0 To calendarpath.Length - 1
                If calendarpath(i) <> "" And calendarpath(i) <> "Public Folders" Then
                    olPublicFolder = olPublicFolder.Folders.Item(calendarpath(i))
                End If
            Next
    
            olAppt = olPublicFolder.Items.Add("IPM.Appointment")
            olAppt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
    
            With olAppt
                .Subject = ("Requested (ID-" & br.request_id & "): " & br.project_name & "-" & Me.typeCombobox.SelectedItem(1))
                .Location = br.bench_name
                If IsDBNull(br.setups_string) Then
                    bodytext = br.comments & vbCrLf & vbCrLf & "Bench Setups Requested:" & vbCrLf & br.setups_string.ToString
                Else
                    bodytext = br.comments
                End If
                .Body = bodytext
                .Start = CDate(br.requestdate & " " & br.start_time)
                .ReminderMinutesBeforeStart = 15
                .ReminderSet = True
                .Duration = DateDiff(DateInterval.Minute, (br.requestdate & " " & br.start_time), (br.requestdate & " " & br.end_time))
    
                For Each recip As String In br.requiredusers_email
                    .Recipients.Add(recip)
                    .Recipients(recip).Type = Outlook.OlMeetingRecipientType.olRequired
                Next
    
                For Each recip As String In br.optionalusers_email
                    .Recipients.Add(recip)
                    .Recipients(recip).Type = Outlook.OlMeetingRecipientType.olOptional
                Next
    
                .Recipients.ResolveAll()
                .Categories = "Yellow Category"
                .ResponseRequested = True
                .BusyStatus = Outlook.OlBusyStatus.olBusy
                .Save()
            End With
    
            entryid = olAppt.EntryID
            olAppt.Save()

    Approval code:

            Dim olApp As New Outlook.Application
            Dim olNameSpace As Outlook.NameSpace = olApp.GetNamespace("MAPI")
            Dim olPublicFolder As Outlook.MAPIFolder
            Dim olAppt As Outlook.AppointmentItem
    
            olApp = CreateObject("Outlook.Application")
            olNameSpace.Logon("Bench Scheduler", "", False, False)
    
            olPublicFolder = olNameSpace.Folders("Public Folders - BenchScheduler@uuu.com")
            For i As Integer = 0 To calendarpath.Length - 1
                If calendarpath(i) <> "" And calendarpath(i) <> "Public Folders" Then
                    olPublicFolder = olPublicFolder.Folders.Item(calendarpath(i))
                End If
            Next
            On Error Resume Next
    
            Dim oItems As Outlook.Items = olPublicFolder.Items
    
            For i As Integer = 1 To oItems.Count
                'Test to make sure item is a mail item and not a meeting request.
                If InStr(oItems.Item(i).subject.ToString, "ID-" & requestid) > 0 Then
                    olAppt = oItems(i)
                    Exit For
                End If
            Next
    
            With olAppt
                .Subject = Replace(.Subject, "Requested", "Approved")
                .Categories = "Green Category"
                .Save()
                .Send()
            End With

    What am I missing?  This is killing me.  This is my last obstacle before being done with this application.  Any help would be greatly appreciated.


    Ken Slovak MVP - Outlook
    Tuesday, May 7, 2013 7:00 PM
    Moderator
  • Ok, i understand about the sessions, etc. 

    As for the accounts, if i go to account settings, there will be two items in the email tab.  The first is Microsoft exchange(which will be the persons company email account and is the default) and the account that I have created (the special user).  Why cant i create the meeting as that other user, the non default one.  If i look at mail profiles, there is only 1, this is different than what 2007 was like.

    As for creating it on a public calendar, that actually works.  I first create the meeting, add the people, etc, then save it with Request in the title.  Once someone approves it, it changes Request to Approved in the title, saves it, then sends invites.  This part actually works, sort of (meaning my issue above).

    What suggestions do you have to make this work.  Basically I want someone to request the meeting with the "Bench Scheduler" email account that they have added to their outlook.  Then someone else can go in and approve it under the same "Bench Scheduler"  email account, which they have also added to their email accounts.

    Wednesday, May 8, 2013 5:19 PM
  • "To do what you want each user would have to log into Outlook as that special user you created, not as themselves. I'm not sure the architecture of what you designed can be made to work."

    How do you log in as a different user.  Both account show up in my navigation.  There is only one mail profile. See image. 

    Or do I have to do it like this?

    Also, I am not doing this from within outlook.  It is from a windows forms application.  I am just interacting with outlook.


    • Edited by DavidKMD Wednesday, May 8, 2013 8:27 PM
    Wednesday, May 8, 2013 8:18 PM
  • You are doing this from Outlook if you you are using Outlook automation code. You can set up a profile to the Exchange server for the user you want, logging into that mailbox as that user. That's what your code has to do.

    Ken Slovak MVP - Outlook

    Thursday, May 9, 2013 6:10 PM
    Moderator
  • I am not sure I get it.  I need to add a new profile other than Default Outlook Profile?
    Thursday, May 9, 2013 8:31 PM
  • You need to set up a profile for whatever "user" owns that mailbox, using the mailbox as the default store for that profile. Wherever that application runs would have to log into Outlook using that profile.

    Ken Slovak MVP - Outlook

    Thursday, May 9, 2013 8:39 PM
    Moderator
  • So if they have outlook open already under their default profile, can i login to the new profile and do what i need to do?
    Monday, May 13, 2013 1:42 PM
  • No, that will not work. You can only have 1 Outlook session running.

    As I said earlier in the thread I don't think you can make this architecture work for what you want.

    It's just not the way Outlook works, and no matter how much you try you can't change how Outlook works.


    Ken Slovak MVP - Outlook

    Monday, May 13, 2013 2:16 PM
    Moderator
  • I knew it wouldnt work in 2007, but with 2010 you can have different stores within your default profile, isnt that correct?  So I thought with that change it would be able to work.
    Tuesday, May 14, 2013 1:10 PM
  • You can have many different stores opened in any Outlook profile and you've been able to do that for many years. Even in Outlook 2000 or earlier I usually opened my default profile with at least 4 mailboxes plus a public folders store, now I usually open my profile with 7 stores opened.

    What Outlook 2010 did was allow you to have more than 1 email account for Exchange at a time in the profile without using delegate mailboxes or using IMAP or other workaround to open the oither mailbox. But one of those mailboxes is still your defauit mailbox and store even in 2010 or 2013.

    I just don't see how what you want will work the way you want just using the Outlook object model. It could possibly work using Redemption or Extended MAPI, or EWS code maybe, but I don't see how with Outlook code.


    Ken Slovak MVP - Outlook

    Tuesday, May 14, 2013 3:18 PM
    Moderator