To Antonio : my Outlook problem

To Antonio : my Outlook problem

Postby driessen » Fri Jun 13, 2008 2: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 :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby NK » Fri Jun 13, 2008 2:45 pm

Test this sample

Code: Select all  Expand view
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
User avatar
NK
 
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany

Postby driessen » Fri Jun 13, 2008 3: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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby James Bott » Fri Jun 13, 2008 4:09 pm

Michel,

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

James

Code: Select all  Expand view
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)
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Otto » Fri Jun 13, 2008 4: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
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Postby driessen » 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 :
Code: Select all  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Antonio Linares » Sat Jun 14, 2008 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » 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

Code: Select all  Expand view
oOutlook:CreateItem(1)


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests