FOr awhile now i been messing around with reoccurng appointments in outlook and this was a tricky issue i was faceing. Along with appts that were several days long. Well i fixed some things with this. And some of this code isn't my original work. A fellow helped me out with and i just modified and tweaked it to my own.
Now i figured i'd share it with anyone who wanted to know. This snippet is without redemption so others may use it who don't have redemption.
Now i figured i'd share it with anyone who wanted to know. This snippet is without redemption so others may use it who don't have redemption.
Code:
DEFINE VARIABLE cEndTime AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFilter AS CHARACTER NO-UNDO.
DEFINE VARIABLE cImport AS CHARACTER NO-UNDO.
DEFINE VARIABLE cLocation AS CHARACTER NO-UNDO.
DEFINE VARIABLE cStartDate AS CHARACTER NO-UNDO.
DEFINE VARIABLE cStartTime AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSubject AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTheDay AS CHARACTER NO-UNDO.
DEFINE VARIABLE hAppt AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hAppts AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hNameSpace AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hOutlook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE iTime AS INTEGER NO-UNDO.
DEFINE TEMP-TABLE ttAppts NO-UNDO
FIELD ttaLocation AS CHARACTER
FIELD ttaSubject AS CHARACTER
FIELD ttaDate AS CHARACTER
FIELD ttaStart AS CHARACTER
FIELD ttaEnd AS CHARACTER.
CREATE "Outlook.Application" hOutlook.
ASSIGN
hNameSpace = hOutlook:GetNameSpace("MAPI")
hAppts = hNameSpace:GetDefaultFolder(9):Items /* Calendar */
cTheDay = STRING(TODAY)
cFilter = "[Start] >= '" + cTheDay + " 00:00 am" + "' and [Start] <= '" + cTheDay + " 11:59 pm'"
cFilter = cFilter + " or " + "[End] >= '" + cTheDay + " 00:00 am" + "' and [End] <= '" + cTheDay + " 11:59 pm'"
cFilter = cFilter + " or " + "[Start] <= '" + cTheDay + " 00:00 am" + "' and [End] >= '" + cTheDay + " 11:59 pm'".
hAppts:SORT("[Start]").
hAppts:IncludeRecurrences = True.
hAppts = hAppts:Restrict(cFilter).
hAppts:SORT("[Start]").
hAppt = hAppts:GetFirst.
DO WHILE hAppt <> 0:
IF hAppt = 0 THEN LEAVE.
hAppt:saveas("c:\temp\importol.txt",0) NO-ERROR.
IF SEARCH("c:\temp\importol.txt") = ? THEN LEAVE.
INPUT FROM "c:\temp\importol.txt" NO-ECHO.
REPEAT:
IMPORT UNFORMATTED cImport.
IF cImport = " ":U THEN NEXT.
IF cImport BEGINS "When:":U THEN /* Meeting Request */
DO:
ASSIGN
cStartTime = cImport
cEndTime = cStartTime
iTime = INDEX(cStartTime,":":U,7)
iTime = iTime - 2
cStartTime = SUBSTRING(cStartTime,iTime,8)
iTime = INDEX(cEndTime,":":U,iTime + 3)
iTime = iTime - 2
cEndTime = SUBSTRING(cEndTime,iTime,8)
cStartDate = SUBSTRING(cImport,iTime - 15,14).
IF cEndTime BEGINS "-":U THEN
ASSIGN cEndTime = SUBSTRING(cEndTime,2,LENGTH(cEndTime) - 1).
END.
IF cImport BEGINS "Start:":U THEN /* Appointment */
DO:
ASSIGN
cStartTime = cImport
iTime = INDEX(cStartTime,":",15)
iTime = iTime - 2
cStartTime = SUBSTRING(cStartTime,iTime,8)
cStartDate = SUBSTRING(cImport,iTime - 15,14).
END.
IF cImport BEGINS "End:":U THEN
ASSIGN
cEndTime = cImport
iTime = INDEX(cEndTime,":",15)
iTime = iTime - 2
cEndTime = SUBSTRING(cEndTime,iTime,8).
END.
INPUT CLOSE.
CREATE ttAppts.
ASSIGN
ttaLocation = hAppt:Location
ttaSubject = hAppt:Subject
ttaDate = cStartDate
ttaStart = cStartTime
ttaEnd = cEndTime.
hAppt = hAppts:GetNext.
END.
ASSIGN
hOutlook = ?
hAppt = ?
hNameSpace = ?
hAppts = ?.
FOR EACH ttAppts:
DISPLAY
ttaLocation
ttaSubject
ttaDate FORMAT "x(15)"
ttaStart
ttaEnd.
END.