for each item In folder:Items
for each attachment In item:Attachments
...
next
next
#include 'fivewin.ch'
#DEFINE olFolderCalendar 9
#DEFINE olFolderContacts 10
#DEFINE olFolderDeletedItems 3
#DEFINE olFolderInBox 6
#DEFINE olFolderJournal 11
#DEFINE olFolderNotes 12
#DEFINE olFolderOutBox 4
#DEFINE olFolderSentMail 5
#DEFINE olFolderTask 13
#DEFINE olBusy 2
#DEFINE olPrivate 2
#DEFINE MAILITEM 0
#DEFINE IMPORTANCELOW 0
#DEFINE IMPORTANCENORMAL 1
#DEFINE IMPORTANCEHIGH 2
#define TEST
#ifdef TEST
function Main()
local cID, lResult
SET CENTURY ON
SET DATE ITALIAN
MsgInfo( 'Start' )
CursorWait()
cID := nil
OutLookAppointment( @cID, Date() + 10 + 10/24, ;
'Subject for testing', ;
'Body for testing', 10, 30, .t. )
msginfo( '|' + cID + '|', 'inserted' )
if ! Empty( cID )
OutLookAppointment( cID, Date() + 5 + 11/24 ) // Modify appointment
msginfo( 'modified' )
OutLookAppointment( cID, .t. ) // display appointment
msginfo( 'displayed' )
if MsgYesNo( 'Delete the appointment?' )
OutLookAppointment( cID, .f. ) // delete appointment
msginfo( 'deleted' )
endif
endif
CursorArrow()
MsgInfo( 'Done' )
return nil
#endif
function OutLookObject()
local cApp := 'OutLook.Application'
local oOutLook
TRY
oOutLook := GetActiveObject( cApp )
CATCH
TRY
oOutLook := CreateObject( cApp )
CATCH
END
END
return oOutLook
function OutLookAppointment( ;
cID, ; // See notes
dDateTime, ; // DateTime var of appointment
cSubject, ;
cBody, ;
nDurationMinutes, ; // Duration in minutes, Default 5 mins
nReminderMinutes, ; // Default no reminder
lBusyStatus ) // Default not busy
/*
* Should have minimum two parameters
* if cID is nil and by ref, and 2nd parameter is date,
* cID is created and returned in the first param
* if cID has valid ID and
* if second paramter is logical
* if .t. item is displayed
* if .f. item is deleted
* if second parameter is not logical
* appointment is modified and saved
*
* Returns success or failure as logical
*/
local oOutLook, oItem, oNameSpace, oFolder, o
local lEdited := .t.
local lSuccess := .f.
if PCount() > 1
TRY
oOutLook := OutLookObject()
// oNameSpace & oFolder need not be used if the appln is runnning
// This code runs whether the app is running or not
oNameSpace := oOutLook:GetNamespace( "MAPI" ) // Alternative oOutLook:Session is identical
oFolder := oNameSpace:GetDefaultFolder( olFolderCalendar ) // Constant value is 9
if cID == nil
if PCount() > 1 .and. dDateTime != nil
// oItem := oOutLook:CreateItem( 1 ) // not used bcuz this does not give EntryID if app is not running
oItem := oFolder:Items:Add()
DEFAULT nDurationMinutes := 5, ;
lBusyStatus := .f.
endif
else
// oItem := oNameSpace:GetItemFromID( cID ) // Fails if the app is not running
// Therefore this second approach, which works even when app is not running
for each o in oFolder:Items
if o:EntryID == cID
oItem := o
exit
endif
next o
endif
if oItem != nil
if ValType( dDateTime ) == 'L'
// Display or Delete
if dDateTime // 2nd parameter is true, Display
oItem:Display()
lSuccess := .t.
else // 2nd Parameter is false, Delete
oItem:Delete()
lSuccess := .t.
endif
else
// Create or Modify
WITH OBJECT oItem
if ValType( dDateTime ) $ 'DT'
:Start := dDateTime; lEdited := .t.
endif
if ValType( cSubject ) == 'C'
:Subject := cSubject; lEdited := .t.
endif
if ValType( cBody ) == 'C'
:Body := cBody; lEdited := .t.
endif
if ValType( nDurationMinutes ) == 'N'
:Duration := nDurationMinutes; lEdited := .t.
endif
if ValType( lBusyStatus ) == 'L'
:BusyStatus := lBusyStatus
endif
if ValType( nReminderMinutes ) == 'N'
:ReminderMinutesBeforeStart := nReminderMinutes
:ReminderSet := .t.
lEdited := .t.
endif
if lEdited
:Save()
if cID == nil
cID := oItem:EntryID
endif
lSuccess := .t. // Created or Modified
elseif cID == nil
// new item created but no valid data
oItem:Delete()
endif
END
endif
endif // if oItem != nil
CATCH
END
endif
return lSuccess
//------------------------------------------------------------------//
oCalendar:Item:SentOn
oCalendar:Item:CreationTime
oCalendar:Item:ReceivedTime
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Marc Venken, Silvio.Falconi and 106 guests