Sample code for creating Tasks in Outlook via VFP

As I mentioned in my last email about TaskLine, here’s the code I used to create a task in Outlook:

crlf = CHR(13)+CHR(10)

lo = GETOBJECT(,”Outlook.application”)

loSpace = lo.GetNameSpace(“MAPI”)

loTasks = loSpace.Folders(“Mailbox”).Folders(“Tasks”)

loTask = loTasks.Items.add()

loTask.subject = TRIM(synopsis)

loTask.startdate = entdate

loTask.categories = “Automatic Call” && This was done to categorize it faster

lcBody = “ID: ” +LTRIM(STR(callid))+crlf+”Customer: “+ custcode + crlf

lcBody = lcBody + “Status: ” +callstat + crlf

lcBody = lcBody + “Type: ” +calltype+ crlf

lcBody = lcBody + “Severity: ” +severity+ crlf

lcBody = lcBody + “Contact : ” +cntname+ crlf

lcBody = lcBody + “Application: ” +appname+ crlf

lcBody = lcBody + TRIM(calldetl) + crlf

lcBody = lcBody + TRIM(workdetl) + crlf

IF NOT ISNULL(duedate)

loTask.DueDate = duedate

ELSE

lotask.duedate = MAX(DATE()+15,TTOD(entdate)+30)

ENDIF

** This is important because the Task Status is a numeric value

DO CASE

CASE callstat=”Follow-Up”

loTask.Status =4 && Waiting on someone else

CASE callstat=”Call Back”

loTask.Status = 4

CASE callstat=”New”

loTask.Status = 0 && Not Started

OTHERWISE

loTask.Status = 1 && In progress

ENDCASE

loTask.totalwork = 120

loTask.Companies = TRIM(custcode)

loTask.Body = lcBody

loTask.Save()

Then I let TaskLine do the rest.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Contact

48 Stonemeadow Drive
Kanata, Ontario K2M2K2

+1 613-851-4496 Contact Us

Connect

Newsletter

Coming Soon