Solved

Add calendar appointment to public folders

Posted on 2013-02-07
2
1,036 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 50

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studios 1 89
Crystal reports login after closing form 3 35
How do I copy a form and rename it in VS2015 2 21
Set arraylist as datatable 2 8
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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

733 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