Solved

Add calendar appointment to public folders

Posted on 2013-02-07
2
996 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
2 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 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:sedgwick
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
A short film showing how OnPage and Connectwise integration works.

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now