Page 1 of 1

Urgent question about Outlook

Posted: Tue Mar 20, 2007 3:43 pm
by driessen
Hello,

I urgently need some WORKING examples for my FW application to :

1. Read an appointment out of Outlook
2. Write an appointment to Outlook
3. Read a task out of Outlook
4. Write a task to Outlook
5. Read messages from the Inbox.

Can someone provide these to me ?

Thank you very much in advance.

Michel

Re: Urgent question about Outlook

Posted: Tue Mar 20, 2007 6:11 pm
by Enrico Maria Giordano
This is a working sample for Inbox:

Code: Select all

#define olFolderInbox 6


FUNCTION MAIN()

    LOCAL oOutlook := CREATEOBJECT( "Outlook.Application" )
    LOCAL oNameSpace := oOutlook:GetNameSpace("MAPI")
    LOCAL oInbox := oNameSpace:GetDefaultFolder( olFolderInbox )

    LOCAL i

    FOR i = 1 TO oInbox:Items:Count
        ? oInbox:Items[ i ]:Body
        ?
    NEXT

    oOutlook:Quit()

    RETURN NIL
EMG

Re: Urgent question about Outlook

Posted: Wed Mar 21, 2007 6:18 pm
by NK
Sample for Add-Task

Code: Select all

FUNCTION AddOLTask( cDate, cSubject, cNotiz, 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() )
      SET CENTURY ON
      SET Date TO GERMAN
      OLESetProperty( hAppItem, "Duration", 60 )
      OLESetProperty( hAppItem, "Subject", cSubject )
      OLESetProperty( hAppItem, "Body", cNotiz )
      OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
      OLEInvoke( hAppItem, "Save" )
      hAppItem := NIL
      hOutlook := NIL
      lSave := .t.
   CATCH
      lSave := .f.
   END
RETURN (lSave)


Re: Urgent question about Outlook

Posted: Wed Mar 21, 2007 6:24 pm
by NK
Sample Add appointment

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: Thu Mar 22, 2007 1:02 am
by driessen
Thanks, guys.

I'll try out your code.

And I hope there is more to come here.

Thank you su much.

Michel