Solved

Add calendar appointment to public folders

Posted on 2013-02-07
2
980 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 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

11 Experts available now in Live!

Get 1:1 Help Now