FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Createitem() in Outlook on Microsoft Exchange
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Createitem() in Outlook on Microsoft Exchange
Posted: Tue Nov 19, 2013 10:10 AM

Hello,

I use "oOutlook:Createitem(1)" to create a new item in the calendar of Outlook.

The item is sended to the standard calender in Outlook.

But now I'm using Microsoft Exchange and I want to sent an item to a calendar which is not the standard calendar of the user, but a shared calender.

How can create a new item in a shared calender on a Microsoft Exchange server?

Thanks a lot in advance for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Createitem() in Outlook on Microsoft Exchange
Posted: Wed Nov 20, 2013 06:16 AM
Here is a VB Code, which may be useful for you.

You can use the Namespace.GetSharedDefaultFolder method to access the Calendar folder in another Exchange mailbox. Keep in mind that you might not have permission to even see that folder, or you might have only read access.

Code (fw): Select all Collapse
Sub CreateOtherUserAppointment()
    Dim objApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objFolder As Outlook.MAPIFolder
    Dim objDummy As Outlook.MailItem
    Dim objRecip As Outlook.Recipient
    Dim objAppt As Outlook.AppointmentItem
    Dim strMsg As String
    Dim strName As String
    On Error Resume Next
     
    ' ### name of person whose Calendar you want to use ###
    strName = "FlaviusJ"
     
    Set objApp = CreateObject("Outlook.Application")
    Set objNS = objApp.GetNamespace("MAPI")
    Set objDummy = objApp.CreateItem(olMailItem)
    Set objRecip = objDummy.Recipients.Add(strName)
    objRecip.Resolve
    If objRecip.Resolved Then
        On Error Resume Next
        Set objFolder = _
          objNS.GetSharedDefaultFolder(objRecip, _
            olFolderCalendar)
        If Not objFolder Is Nothing Then
            Set objAppt = objFolder.Items.Add
            If Not objAppt Is Nothing Then
                With objAppt
                    .Subject = "Test Appointment"
                    .Start = Date + 14
                    .AllDayEvent = True
                    .Save
                End With
            End If
        End If
    Else
        MsgBox "Could not find " & Chr(34) & strName & Chr(34), , _
               "User not found"
    End If
 
    Set objApp = Nothing
    Set objNS = Nothing
    Set objFolder = Nothing
    Set objDummy = Nothing
    Set objRecip = Nothing
    Set objAppt = Nothing
End Sub


Regards
Anser
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Createitem() in Outlook on Microsoft Exchange
Posted: Wed Nov 20, 2013 09:56 AM

Thanks a lot, Anser.
I'm going to try it out.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion