Page 1 of 1

Create appointment in outlook

Posted: Fri Nov 16, 2007 12:40 am
by cdmmaui
Hello,

Can you someone provide an example of how to create an appointment in outlook.

Thank you,

Posted: Fri Nov 16, 2007 1:27 am
by James Bott
I copied this from another message. I have never tried it and you probably don't need the SET DATE TO GERMAN unless you are Germany.

James

Code: Select all

FUNCTION AddOLappointment( cDate, cTime, nLenInMin, cSubject, cNotiz ) 

   LOCAL hOutlook 
   LOCAL hApptItem 
   LOCAL dDate 
   LOCAL lSave := .F. 
   TRY 
      hOutlook  := CreateOLEObject( "Outlook.Application" ) 
      hAppItem  := OLEInvoke( hOutlook, "CreateItem", 1 ) 

      SET CENTURY ON 
      dDate := CToD( cDate ) 
      OLESetProperty( hAppItem, "Start", cDate + " " + cTime ) 
      OLESetProperty( hAppItem, "StartTime", cTime + ":00" ) 
      SET CENTURY ON 
      SET Date TO GERMAN 
      OLESetProperty( hAppItem, "Duration", nLenInMin * 60 ) 
      OLESetProperty( hAppItem, "Subject", cSubject ) 
      OLESetProperty( hAppItem, "Body", cNotiz ) 
      OLESetProperty( hAppItem, "Mileage", 225 ) 
      OLEInvoke( hAppItem, "Save" ) 
      hAppItem := NIL 
      hOutlook := NIL 
      lSave := .t. 
   CATCH 
      lSave := .f. 
   END 
RETURN (lSave) 

Posted: Fri Nov 16, 2007 2:12 am
by cdmmaui
Hi James,

Thanks for your help!

Regards,

Posted: Fri Nov 16, 2007 8:48 am
by Enrico Maria Giordano
James, why do you use OLEInvoke() and OLESetProperty() instead of the common object oriented syntax? As an example:

hAppItem := hOutlook:CreateItem( 1 )

And, by the way, I would name hOutlook and hAppItem as oOutlook and oAppItem.

EMG

Posted: Fri Nov 16, 2007 8:54 am
by James Bott
Enrico,

>James, why do you...

I didn't write it.

James

Posted: Fri Nov 16, 2007 10:37 am
by Enrico Maria Giordano
Ops! Sorry. :-)

EMG