How to create appointment in shared folder in outlook.
I can create items in my default folder using createitem(1).
Here is code i have written so far.
DEFINE VARIABLE hOutlook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMyNameSpace AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMyFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMySharedFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hrecipient AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hItem AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hentry AS COM-HANDLE NO-UNDO.
CREATE "Outlook.Application" hOutlook.
ASSIGN
hMyNameSpace = hOutlook:GetNameSpace("MAPI")
hrecipient = hMyNameSpace:CreateRecipient("Sachindra Maharjan") NO-ERROR.
hrecipient:Resolve().
IF hrecipient:Resolved THEN
DO:
hMySharedFolder = hMyNameSpace:GetSharedDefaultFolder(hrecipient, 9) NO-ERROR.
END.
hItem = hMySharedFolder:Items.
hMySharedFolder = hItem:ADD("IPM.Appointment").
RELEASE OBJECT hOutlook NO-ERROR.
RELEASE OBJECT hMyNameSpace NO-ERROR.
RELEASE OBJECT hMyFolder NO-ERROR.
RELEASE OBJECT hMyNextFolder NO-ERROR.
RELEASE OBJECT hrecipient NO-ERROR.
RELEASE OBJECT hItem NO-ERROR.
RELEASE OBJECT hentry NO-ERROR.
Thank you.
Here is the complete code to create appointment in shared folder in outlook.
DEFINE VARIABLE hOutlook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMyNameSpace AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMyFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMyNextFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hrecipient AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hItem AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hentry AS COM-HANDLE NO-UNDO.
CREATE "Outlook.Application" hOutlook.
ASSIGN
hMyNameSpace = hOutlook:GetNameSpace("MAPI")
hrecipient = hMyNameSpace:CreateRecipient("SharedFolderName") NO-ERROR.
hrecipient:Resolve().
IF hrecipient:Resolved THEN
DO:
hMyNextFolder = hMyNameSpace:GetSharedDefaultFolder(hrecipient, 9) NO-ERROR.
END.
hItem = hMyNextFolder:Items.
ASSIGN
hMyNextFolder = hItem:ADD("IPM.Appointment")
hMyNextFolder:subject = "This is a test message"
hMyNextFolder:START = "14/11/11 12:00 AM"
hMyNextFolder:END = "14/11/11 12:00 PM"
hMyNextFolder:body = "This is a test message"
hMyNextFolder:AllDayEvent = TRUE.
hMyNextFolder:SAVE().
hMyNextFolder:SEND().
RELEASE OBJECT hOutlook NO-ERROR.
RELEASE OBJECT hMyNameSpace NO-ERROR.
RELEASE OBJECT hMyFolder NO-ERROR.
RELEASE OBJECT hMyNextFolder NO-ERROR.
RELEASE OBJECT hrecipient NO-ERROR.
RELEASE OBJECT hItem NO-ERROR.
RELEASE OBJECT hentry NO-ERROR.