[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add calendar appointment to public folders

Posted on 2013-02-07
2
Medium Priority
?
1,113 Views
Last Modified: 2013-02-07
Hi.

Im looking for some vb.net code to add a calendar entry to a puiblic folder in outlook.

I can add to my personal mailbox, but not the public folder calendar.

The working code is:

        Dim objOutlook As Outlook.Application
        objOutlook = New Outlook.Application()
        Dim objNS As Outlook.NameSpace = objOutlook.Session
        '---------Write to Shared calendar-----------------
                Dim objFolder As Outlook.MAPIFolder = objNS.Folders.Item("my@email.com")
        	objFolder = objFolder.Folders.Item("Calendar")
        '=========Add appointment to calendar=================
        Dim objApp As Outlook.AppointmentItem
        objApp = CType(objFolder.Items.Item(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)
        With objApp
            .Subject = calSubject
            '.Location = "Main Office"
            .Body = (calBody)
            .Start = CDate(calDateStart & " 09:00")
            ' Added a reminder
            .ReminderMinutesBeforeStart = 1
            .ReminderSet = True
            ' Added duration
            '.Duration = 120
            ' Add logged in Windows user
            .RequiredAttendees = Environment.UserName
            ' Save first
            .Save()
            ' Send to logged in Windows user
            .Send() 
        End With

Open in new window


My public calendar is in Public Folders > All Public Folders > Logistics

I have tried settings the mapi folder as the full path but still cant get it to add

Any help would be great,

Thanks
0
Comment
Question by:norman_cook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 38863712
Hi,


This could help:

Please refer to http://social.msdn.microsoft.com/Forums/en-GB/outlookdev/thread/6749ee0f-62a2-4315-b46f-d663ab7dbfed

To open another user's Calendar folder, call Namespace.GetSharedDefaultFolder(..., olFolderCalendar).

If you want a folder in the PF store, open the root Public Folder (Namespace.GetDefaultFolder(olPublicFoldersAllPublicFolders), then drill down to the desired folder using the Folders collection

set Subfolder = RootFolder.Folders('subfolder 1").Folders('subfolder 2")


--------------------------------------------------------------------------------
Regards
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 38863735
try this function to get public folder:

' GetFolder - Gets a Public folder based on a string path - e.g. 
'If Folder name in English is
'Public Folders\All Public Folders\Europeen Workflow
'The just pass in "Europeen Workflow'
Public Function GetPublicFolder(strFolderPath)
    
    Dim colFolders 
    Dim objFolder 
    Dim arrFolders 
    Dim i 
    On Error Resume Next
    strFolderPath = Replace(strFolderPath, "/", "\")
    arrFolders = Split(strFolderPath, "\")
     
    Set objFolder = Application.Session.GetDefaultFolder(18)
    Set objFolder = objFolder.Folders.Item(arrFolders(0))
    If Not objFolder Is Nothing Then
        For i = 1 To UBound(arrFolders)
            Set colFolders = objFolder.Folders
            Set objFolder = Nothing
            Set objFolder = colFolders.Item(arrFolders(i))
            If objFolder Is Nothing Then
                Exit For
            End If
        Next
    End If
    Set GetPublicFolder = objFolder
    Set colFolders = Nothing
     Set objApp = Nothing
    Set objFolder = Nothing
End Function

Open in new window


from GetPublicFolder
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question