Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Outlook Automation
Message
From
01/08/2000 12:08:27
 
 
To
30/07/2000 07:25:41
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00398593
Message ID:
00399393
Views:
21
Hi Matt,

You and Tamar were on the right track: The reason that your code acted so flaky was that Outlook couldn't tell where to put the Task when it was not explicitly open. This is why you need the Namespace and the default MAPI folders to automate Tasks (and other stuff too). Try the code below (I modified your code):
*// Folder Constants
#DEFINE olFolderCalendar 9
#DEFINE olFolderContacts 10
#DEFINE olFolderDeletedItems 3
#DEFINE olFolderInBox 6
#DEFINE olFolderJournal 11
#DEFINE olFolderNotes 12
#DEFINE olFolderOutBox 4
#DEFINE olFolderSentMail 5
#DEFINE olFolderTask 13
#DEFINE olBusy 2
#DEFINE True .T.
#DEFINE False .F.
#DEFINE olPrivate 2

*/ Importance Constants
#DEFINE olImportanceLow 0
#DEFINE olImportanceNormal 1
#DEFINE olImportanceHigh 2


*// Item Constants
#DEFINE olMailItem 0
#DEFINE olAppointmentItem 1
#DEFINE olContactItem 2
#DEFINE olTaskItem 3
#DEFINE olJournalItem 4
#DEFINE olNoteItem 5
#DEFINE olPostItem 6

*// Added a Folder Constant

#DEFINE olFolderTasks 13

*// Create the Outlook Object
Public oOutLookObject
oOutLookObject = CreateObject("Outlook.Application")

*// Added code for alternate creating of Task

oNameSpace=oOutlookObject.GetNameSpace("MAPI")
oTaskFolder=oNameSpace.GetDefaultFolder(olFolderTasks)
oTaskItem=oTaskFolder.Items.Add

WITH oTaskItem
 .Subject = "My Subject"
 .Body = "My Body"
 .StartDate = date()
 .DueDate = date() + 10
 .ReminderSet = True
 .ReminderTime = datetime() + 3600
 .Categories = "Personal"
 .Save
EndWith

release oTaskItem
release oOutLookObject
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform