Solved

Add calendar appointment to public folders

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

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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