Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hooking into Outlook Events
Message
 
To
02/11/2006 13:07:40
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01166586
Message ID:
01166729
Views:
17
>>With my previous version of Outlook, I was able to open the object in my object inspector and use EVENTHANDLER() to bind my own events class to the application.
>>
>>I now have Office 2003 and I can no longer find the Outlook object in the object browser, nor can I seem to figure out how to bind to its events.
>
>The library you're looking for is Microsoft Outlook 11.0 Object Library.
>
>Tamar

Using the object browser, I get no such object in my COM Libraries list. I did however find
Microsoft.Office.Interop.Outlook, Version=11.0.0.0 ...
Using this I was able to create a class definition for MailItems. However, the code crashes every time I try to run it.

Here is my code:
oapp = CREATEOBJECT("Outlook.Application")

oEvents=NEWOBJECT("myclass")

oItem = oapp.createItem(0)
EVENTHANDLER(oItem,oEvents)

oItem.Subject = "Test"
oItem.Display

RETURN

DEFINE CLASS myclass AS session OLEPUBLIC

   IMPLEMENTS _MailItem IN "Outlook.MailItem"

   ... 

   PROCEDURE _MailItem_Send() AS VOID
   * add user code here
      = MESSAGEBOX("Mail was sent")
   ENDPROC

   ...

ENDDEFINE
I expect I'm going to run into a scoping issue with this code, but I'm not even getting that far. This code crashes on the line trying to instantiate my class. I get the message: Type Library Outlook.MailItem not found.

Any ideas what the problem might be?

Thanks for your help.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform