Hello,
Already several times, I asked about some more information concerning communications with Microsoft Outlook through OLE.
My customers are asking for more possibilities in this almost every day.
Until now, nobody has given me a satisfying answer.
What do I need :
- Sending and receiving emails from Outlook
- Synchronisation with the Outlook Calender
- Saving the attachments from a e-mail-message
- Exporting data to Excel
- ...
Please can someone tell me if a solution is possible ? To my opinion there is a great need for such solutions. It's one of the issues of modern software.
I hope someone can help me because I'm getting disperate.
Thank you very much in advance.
Urgent problem
Urgent problem
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Urgent problem
Michel
here are some handy functions for outlook
For email, there has been many threads in this forum.
Functions below are used by my app
#define outlookFolderCalendar 9
#define olFolderContacts 10
FUNCTION AJRDV( cDate, cTime, nLenInMin, cObjet, cNote ) // cdate format jj/mm/aaaa ctime format hh:mns EXEMPLE 10:20
LOCAL oOutlook,hApptItem,oNameSpace,ocalendar,hOutlook, ;
lSave := .F., ;
lFOUND := .F., ;
I := 0
TRY
oOutlook := CREATEOBJECT( "Outlook.Application" )
oNameSpace := oOutlook:GetNameSpace("MAPI")
ocalendar := oNameSpace:GetDefaultFolder(outlookFolderCalendar )
FOR I = 1 TO ocalendar:Items:Count
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
IF ! LFOUND // NOUVEAU
hOutlook := CreateOLEObject( "Outlook.Application" )
hAppItem := OLEInvoke( hOutlook, "CreateItem", 1 )
OLESetProperty( hAppItem, "Start", CDate + " " + cTime)
OLESetProperty( hAppItem, "Duration", nLenInMin )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "Mileage", 225 )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
ENDIF
OOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION AJTACHE( cDate, cObjet, cNote, 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() )
OLESetProperty( hAppItem, "Duration", 60 )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION READOUTLOOK()
LOCAL oOutlook := CREATEOBJECT( "Outlook.Application" )
LOCAL oNameSpace := oOutlook:GetNameSpace("MAPI")
LOCAL oContacts := oNameSpace:GetDefaultFolder( olFolderContacts )
LOCAL i
FOR i = 1 TO oContacts:Items:Count
? oContacts:Items[ i ]:FullName
? oContacts:Items[ i ]:BusinessAddressStreet
? oContacts:Items[ i ]:BusinessAddressPostalCode
? oContacts:Items[ i ]:BusinessAddressCity
? oContacts:Items[ i ]:BusinessAddressState
? oContacts:Items[ i ]:BusinessAddressCountry
? oContacts:Items[ i ]:BusinessTelephoneNumber
? oContacts:Items[ i ]:Email1Address
? oContacts:Items[ i ]:LastModificationTime
?
NEXT
oOutlook:Quit()
RETURN NIL
hth
Richard
here are some handy functions for outlook
For email, there has been many threads in this forum.
Functions below are used by my app
#define outlookFolderCalendar 9
#define olFolderContacts 10
FUNCTION AJRDV( cDate, cTime, nLenInMin, cObjet, cNote ) // cdate format jj/mm/aaaa ctime format hh:mns EXEMPLE 10:20
LOCAL oOutlook,hApptItem,oNameSpace,ocalendar,hOutlook, ;
lSave := .F., ;
lFOUND := .F., ;
I := 0
TRY
oOutlook := CREATEOBJECT( "Outlook.Application" )
oNameSpace := oOutlook:GetNameSpace("MAPI")
ocalendar := oNameSpace:GetDefaultFolder(outlookFolderCalendar )
FOR I = 1 TO ocalendar:Items:Count
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
IF ! LFOUND // NOUVEAU
hOutlook := CreateOLEObject( "Outlook.Application" )
hAppItem := OLEInvoke( hOutlook, "CreateItem", 1 )
OLESetProperty( hAppItem, "Start", CDate + " " + cTime)
OLESetProperty( hAppItem, "Duration", nLenInMin )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "Mileage", 225 )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
ENDIF
OOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION AJTACHE( cDate, cObjet, cNote, 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() )
OLESetProperty( hAppItem, "Duration", 60 )
OLESetProperty( hAppItem, "Subject", cObjet )
OLESetProperty( hAppItem, "Body", cNote )
OLESetProperty( hAppItem, "StartTime", cTime + ":00" )
OLEInvoke( hAppItem, "Save" )
hAppItem := NIL
hOutlook := NIL
lSave := .t.
CATCH
lSave := .f.
END
RETURN (lSave)
FUNCTION READOUTLOOK()
LOCAL oOutlook := CREATEOBJECT( "Outlook.Application" )
LOCAL oNameSpace := oOutlook:GetNameSpace("MAPI")
LOCAL oContacts := oNameSpace:GetDefaultFolder( olFolderContacts )
LOCAL i
FOR i = 1 TO oContacts:Items:Count
? oContacts:Items[ i ]:FullName
? oContacts:Items[ i ]:BusinessAddressStreet
? oContacts:Items[ i ]:BusinessAddressPostalCode
? oContacts:Items[ i ]:BusinessAddressCity
? oContacts:Items[ i ]:BusinessAddressState
? oContacts:Items[ i ]:BusinessAddressCountry
? oContacts:Items[ i ]:BusinessTelephoneNumber
? oContacts:Items[ i ]:Email1Address
? oContacts:Items[ i ]:LastModificationTime
?
NEXT
oOutlook:Quit()
RETURN NIL
hth
Richard
Richard,
Thank you very much.
I'll try it out as soon as possible.
This is a step I was looking for.
Many, many thanks.
Thank you very much.
I'll try it out as soon as possible.
This is a step I was looking for.
Many, many thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7