Once again : synchronizing with Outlook through OLE

Once again : synchronizing with Outlook through OLE

Postby driessen » Tue May 20, 2008 4:04 pm

Hello,

I give it another try.

Is someone able to help me to build a synchronization in FWH between a calender in DBF-format and an Outlook calender ?

I am able to read the Outlook data but how do I write a calender item in outlook, how do I delete a calender item in outlook, how can I read which item is the newest : the one in the DBF-file or the one in Outlook ?

Is there any difference between a normal PST-file and Outlook connected to an exchange server ?

Thanks a lot in advance for any help.

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 pymsoft » Wed May 21, 2008 12:30 pm

Michel,


see this:

Code: Select all  Expand view
#define outlookFolderCalendar 9
#define olFolderContacts 10

FUNCTION PrendiDatiOutlook()

LOCAL oOutlook, hApptItem, oNameSpace, ocalendar, hOutlook, ;
  lSave := .F., ;
  lFOUND := .F., ;
  cTxt,;
  I := 0, nItems

TRY

  CursorWait()

IF !FILE( oV:arc_dir + "eventi.dat" )
  DBCREATE( oV:arc_dir + "eventi.dat", {;
          { "EVN_DATE" ,  "D", 8, 0 },;
          { "EVN_TIME" ,  "C", 5, 0 },;
          { "EVN_SUBJ" ,  "C", 20, 0 },;
          { "EVN_IDOUT",  "C", 45, 0 },;
          { "EVN_OP"   ,  "C",  2, 0 },;
          { "EVN_MEMO" ,  "M", 10, 0}})
ENDIF

IF !FILE( oV:arc_dir + "eventi.ind" )
  SELECT 0
  USE ( oV:arc_dir + "eventi.dat" ) NEW ALIAS eventi EXCLUSIVE
  INDEX ON DTOS( FIELD->EVN_DATE ) + FIELD->EVN_TIME TAG uno TO ( oV:arc_dir + "eventi.ind" )
  INDEX ON FIELD->EVN_IDOUT TAG due TO ( oV:arc_dir + "eventi.ind" )
  USE
ENDIF


  SELECT 0
  USE ( oV:arc_dir + "eventi.dat" ) NEW ALIAS eventi SHARED INDEX ( oV:arc_dir + "eventi.ind" )
  eventi->( ordSetFocus(2) )

  oOutlook := CREATEOBJECT( "Outlook.Application" )
 
  oNameSpace := oOutlook:GetNameSpace("MAPI")
  ocalendar := oNameSpace:GetDefaultFolder(outlookFolderCalendar )
 
  FERASE("datiOutlook.txt")
  nItems := ocalendar:Items:Count
  //msginfo( nItems )


  FOR I := 1 TO nItems
    //msginfo( VALTYPE( ocalendar:Items[ i ]:START ) )
    cTxt := PADR( ocalendar:Items[ i ]:ConversationIndex, 45 ) +  " - " + ;
            PADR( ocalendar:Items[ i ]:START, 19 ) + " - " +;
            PADR( ocalendar:Items[ i ]:END, 19 ) + " - " +;
            ocalendar:Items[ i ]:SUBJECT + " - " +;
            ocalendar:Items[ i ]:Body

    IF !eventi->( dbSeek( PADR( ocalendar:Items[ i ]:ConversationIndex, 45 ) ) )
      eventi->( dbAppend() )
      REPLACE eventi->evn_idout WITH PADR( ocalendar:Items[ i ]:ConversationIndex, 45 )
      REPLACE eventi->evn_date WITH CTOD( PADR( ocalendar:Items[ i ]:START, 10 ) )
      REPLACE eventi->evn_time WITH RIGHT( PADR( ocalendar:Items[ i ]:START, 19 ), 8 )
      REPLACE eventi->evn_subj WITH ocalendar:Items[ i ]:SUBJECT
      REPLACE eventi->evn_memo WITH ocalendar:Items[ i ]:BODY
      REPLACE eventi->evn_op WITH cOperatore
    ENDIF

//01C868AF1EC46949DA0314C440AA9FE7C122E63FE176  - 06/02/2008 18:59:59 - 06/02/2008 19:30:00 - PROVA PROVA PROVA 06-02-2008 - PROVA DI TESTO...

    InfStat( cTxt )
    WriteInfoTxt( cTxt, , "datiOutlook.txt", .T. )
    /*
      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

  OOutlook := NIL
  lSave := .t.
CATCH
  lSave := .f.
END

  eventi->( dbCloseArea() )

  CursorArrow()

RETURN NIL
*
**
*




Regards
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby driessen » Wed May 21, 2008 7:57 pm

Pedro,

I am very greatful for your answer.

I'll try it out as soon as possible and I'll put my experiences here.

Thanks once again.

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 driessen » Wed May 21, 2008 8:49 pm

Pedro,

Is it possible that you example only reads the calendar items in Outlook and puts the into a DBF-file ?

What I need is this : I want to read the calender items in Outlook and I add them into DBF if they don't exist yet. But I also want to read calender items in DBF and add them into Outlook. If both items are existing, the oldest one has to be updated by the newest one.

That is real synchronizing.

I need to do the same thing with the tasks.

Any idea ?

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 pymsoft » Thu May 22, 2008 8:38 am

driessen wrote:Pedro,

Is it possible that you example only reads the calendar items in Outlook and puts the into a DBF-file ?


--> Yes:


FOR I := 1 TO nItems
IF !eventi->( dbSeek( PADR( ocalendar:Items[ i ]:ConversationIndex, 45 ) ) )
eventi->( dbAppend() )
REPLACE eventi->evn_idout WITH PADR( ocalendar:Items[ i ]:ConversationIndex, 45 )
REPLACE eventi->evn_date WITH CTOD( PADR( ocalendar:Items[ i ]:START, 10 ) )
REPLACE eventi->evn_time WITH RIGHT( PADR( ocalendar:Items[ i ]:START, 19 ), 8 )
REPLACE eventi->evn_subj WITH ocalendar:Items[ i ]:SUBJECT
REPLACE eventi->evn_memo WITH ocalendar:Items[ i ]:BODY
REPLACE eventi->evn_op WITH cOperatore
ENDIF
NEXT



What I need is this : I want to read the calender items in Outlook and I add them into DBF if they don't exist yet. But I also want to read calender items in DBF and add them into Outlook. If both items are existing, the oldest one has to be updated by the newest one.

--> My example read and save to a DBF.

That is real synchronizing.

I need to do the same thing with the tasks.

Any idea ?

--> Yes, you need to save a new event in outlook, and take a number PADR( ocalendar:Items[ i ]:ConversationIndex, 45 ) UNIQUE and save in your DBF. (the number is something like this: 01C868AF1EC46949DA0314C440AA9FE7C122E63FE176)

Thanks.



Best regards.
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia

Postby driessen » Thu May 22, 2008 8:59 am

Pedro,

Thanks a lot for your answer.

My problem still is :

How do I add, replace of delete items in Outlook ?

If I know how to do that, I think I must be able to establish a real synchronization.

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 pymsoft » Fri May 23, 2008 7:40 am

Michel,

Something like this:


See the function ajrdv of Richard Chidiak


http://fivetechsoft.com/forums/viewtopi ... ight=ajrdv



Best regards
Pedro Gonzalez
User avatar
pymsoft
 
Posts: 383
Joined: Tue Oct 11, 2005 1:01 pm
Location: Savona - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests