by Richard Chidiak » Mon Oct 22, 2007 10:03 am
Michel
here are some handy functions for outlook
For email, there has been many threads in this forum.
Functions below are used by my app
#define outlookFolderCalendar 9
#define olFolderContacts 10
FUNCTION AJRDV( cDate, cTime, nLenInMin, cObjet, cNote ) // cdate format jj/mm/aaaa ctime format hh:mns EXEMPLE 10:20
LOCAL oOutlook,hApptItem,oNameSpace,ocalendar,hOutlook, ;
lSave := .F., ;
lFOUND := .F., ;
I := 0
TRY
oOutlook := CREATEOBJECT( "Outlook.Application" )
oNameSpace := oOutlook:GetNameSpace("MAPI")
ocalendar := oNameSpace:GetDefaultFolder(outlookFolderCalendar )
FOR I = 1 TO ocalendar:Items:Count
IF DTOS(ocalendar:Items[ i ]:START) = DTOS(CTOD(CDATE)) .AND. ocalendar:Items[ i ]:SUBJECT = cObjet ;
.AND. ocalendar:Items[ i ]:Body = cNote .AND. ocalendar:Items[ i ]:Duration = NLeninmin
LFOUND := TRUE
I := 1000000
ENDIF
NEXT
IF ! LFOUND // NOUVEAU
hOutlook := CreateOLEObject( "Outlook.Application" )
hAppItem := OLEInvoke( hOutlook, "CreateItem", 1 )
OLESetProperty( hAppItem, "Start", CDate + " " + cTime)
OLESetProperty( hAppItem, "Duration", nLenInMin )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "Mileage", 225 )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
ENDIF
OOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION AJTACHE( cDate, cObjet, cNote, cTime )
LOCAL hOutlook, hAppItem, dDate
LOCAL lSave := .f.
TRY
hOutlook := CreateOLEObject( "Outlook.Application")
hAppItem := OLEInvoke( hOutlook, "CreateItem", 3 )
dDate := CToD( cDate )
OLESetProperty( hAppItem, "DueDate", dDate )
OLESetProperty( hAppItem, "Remindertime", cDate + " " + cTime )
OLESetProperty( hAppItem, "ReminderSet", "Y" )
OLESetProperty( hAppItem, "StartDate", Date() )
OLESetProperty( hAppItem, "Duration", 60 )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION READOUTLOOK()
LOCAL oOutlook := CREATEOBJECT( "Outlook.Application" )
LOCAL oNameSpace := oOutlook:GetNameSpace("MAPI")
LOCAL oContacts := oNameSpace:GetDefaultFolder( olFolderContacts )
LOCAL i
FOR i = 1 TO oContacts:Items:Count
? oContacts:Items[ i ]:FullName
? oContacts:Items[ i ]:BusinessAddressStreet
? oContacts:Items[ i ]:BusinessAddressPostalCode
? oContacts:Items[ i ]:BusinessAddressCity
? oContacts:Items[ i ]:BusinessAddressState
? oContacts:Items[ i ]:BusinessAddressCountry
? oContacts:Items[ i ]:BusinessTelephoneNumber
? oContacts:Items[ i ]:Email1Address
? oContacts:Items[ i ]:LastModificationTime
?
NEXT
oOutlook:Quit()
RETURN NIL
hth
Richard