FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour To Antonio : my Outlook problem
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 02:01 PM
Hello Antonio,

Thanks for your help until now.

As you asked me to, I'll continue our conversation here.

After your advice of last Wednesday, I tried this code today :
oOutlook         := CreateObject("Outlook.Application")
oNameSpace       := oOutlook:GetNameSpace("MAPI")
oCalendar        := oNameSpace:GetDefaultFolder(outlookFolderCalendar)
oItem            := oOutlook:CreateItem(1)

oItem:Start      := DTOC(AG->AGDATUM) + " " + AG->AGBTIJD
oItem:StartTime  := AG->AGBTIJD + ":00"
oItem:Duration   := Ol1Minuut * 60
oItem:Subject    := ALLTRIM(IF(VAL(AG->AGSRTNR)=0,AG->AGSRTNRN,AG->AGOMSCH))
oItem:Body       := ALLTRIM(cOUTLOMSCH)
oItem:Category   := IF(VAL(AG->AGSRTNR)<=0,"Rechtbank",AG->AGSRTNRN)
oItem:Location   := ALLTRIM(AG->AGVERGNRN)
oItem:Importance := ExPrior
IF AG->ALARM
	oItem:ReminderMinutesBeforeStart := cOl2Minuut * 60
	oItem:ReminderSet := cTRUE
ELSE
  	oItem:ReminderSet := cFALSE
ENDIF
oItem:Save()

oCalendar  := NIL
oNameSpace := NIL
oOutlook   := NIL
oItem      := NIL

Unfortunately the result isn't good.

On line 3 I already get a GPF and my application is closed.

What now ?

Thanks a lot.

Regards.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 97
Joined: Sun Nov 20, 2005 04:32 PM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 02:45 PM
Test this sample

FUNCTION AddOLCalendar( cDate, cTime, nDuration, cTitle, cMemo )

   LOCAL hOutlook
   LOCAL hApptItem
   LOCAL nFolderNr
   hOutlook  := CreateOLEObject( "Outlook.Application" )
   hAppItem  := OLEInvoke( hOutlook, "CreateItem", 1 )
   OLESetProperty( hAppItem, "Start", cDate + " " + cTime )
   OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
   OLESetProperty( hAppItem, "Duration", nDuration * 60 )
   OLESetProperty( hAppItem, "Subject", cTitle )
   OLESetProperty( hAppItem, "Body", cMemo )
   OLESetProperty( hAppItem, "Mileage", 225 )
   OLEInvoke( hAppItem, "Save" )
   hAppItem := NIL
   hOutlook := NIL
RETURN NIL


Regards, Norbert
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 03:30 PM

Norbert,

Thanks for your reply.

Your example doesn't give any errors, but ... I don't find my appointments in Outlook unfortunately.

Any idea why I don't ?

Thanks.

Regards.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 04:09 PM
Michel,

Here is a sample I found in my notes. I have not tried it.

James

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)
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 04:24 PM

Michel,
Are you working with version 2007?
I face the same problem but only if Outlook is closed. If I open Outlook first all works.

Regards,
Otto

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
To Antonio : my Outlook problem
Posted: Fri Jun 13, 2008 10:59 PM
Otto,
James,
Norbert,

Thanks for your help.

I am able to add items to the calendar, but also tasks, in Outlook.

What did I change :

1. You need to use CreateOLEObject() in stead of CreateObject().
2. No use of GetNameSpace()
3. In case of Outlook 2007, Outlook has to be opened, just like Otto said.

The Outlook 2007 problem, I solved by searching for "OUTLOOK" in the array Gettasks().

If Outlook isn't found, I do this :
WINEXEC(cOUTPATH,2)

where cOUTPATH contains the pathname of OUTLOOK.EXE.

Is there another way to launch Outlook ?

Thanks.

Regards.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
To Antonio : my Outlook problem
Posted: Sat Jun 14, 2008 08:24 AM

Michel,

Many thanks for your feedback,

WinExec() is fine. Another way may be ShellExecute() (not tested).

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
To Antonio : my Outlook problem
Posted: Sat Jun 14, 2008 12:31 PM
driessen wrote:1. You need to use CreateOLEObject() in stead of CreateObject().


I strongly recommend CreateObject() as it allows the easier syntax

oOutlook:CreateItem(1)


EMG

Continue the discussion