Skip to main content

Outlook Automation with VFP

An overview of how to automate Outlook with Visual FoxPro.

Comments

Anonymous said…
Hi. I've used the FIND command to find an email msg, task or appointment. What I have a pbm with is the very first time you initiate the find, it takes MINUTES. It acts like it's indexing or something. Then after that initial find, the next time you try to find anything, bam! it finds it (or not) in less than 1 second.

Ideas?
Anonymous said…
Excellent article. Thank you for taking the time to write it. One other issue I'm having is I am (here we go again), finding a public folder and once I find it, I want to display it on screen. I have the object (ie oCalendarFolder) and when I call oCalendarFolder.Display it shows the window, but also returns an error "Display is not a member object".

Ideas?
Anonymous said…
How can Outlook be configured so when my vfp app wants to use it to email a file it doesn't constanly ask if its ok?
Anonymous said…
Forgive my ignorance. I'm new to this way of coding.
Can you tell me the difference in what you've outlined in your white paper where you write:
loApp = CREATEOBJECT("OUTLOOK.APPLICATION")
loSpace = loApp.GetNameSpace("MAPI")
loFolders = loSpace.Folders
loItems = loSpace.Folders.Items

and the follwing:

LOCAL loOutlook, loHandler
loOutlook=CREATEOBJECT( [Outlook.Application] )
loHandler=NEWOBJECT("OutlookHandler")
EVENTHANDLER( loOutlook, loHandler )
SUSPEND
DEFINE CLASS OutlookHandler AS session OLEPUBLIC
IMPLEMENTS ApplicationEvents_10 IN {00062FFF-0000-0000-C000-000000000046}#9.1
PROCEDURE ApplicationEvents_10_ItemSend(Item AS VARIANT, Cancel AS LOGICAL) AS VOID
* add user code here
ENDPROC
Andrew MacNeill said…
Dan,

Great question. The main difference is one of how you react to items. The first approach is useful for actively looking for items without worrying about what the user is doing. You aren't told if there are new emails or new items added - it's more if you are adding items automatically or reviewing existing items.

Using the IMPLEMENT approach, you are able to interact with what the user is doing. For example, when a new message comes in, your Outlook handler can react to it automatically. When a user clicks a button, you can react to it further. There's more code required but more available actions to work from.

For example, if your application, wants to react to new messages as they come in, you would need to use the IMPLEMENTS approach.

Make sense?

Popular posts from this blog

Refactoring T-SQL

While much has been said about the benefits of refactoring application code (see VFPX Code Analyst), I typically haven't seen a lot of noise about refactoring T-SQL and stored procedure code.

The refactoring features found in SQL Manager tend to be more about refactoring your database design but not about the actual content of the SPs.

It's important to note that if you tend to rely on large stored procedures, then many of the same rules of refactoring apply:

1. Keep it short and sweet.
2. Make it readable.


So when dealing with a particularly unruly stored proc (over 1000 lines), I was quite happy to find Red Gate's SQL Refactor (here's a post from the lead developer).

Some of the features are pretty basic (renaming variables, etc) but the one of great interest was the Encapsulate as a new Stored Proc.

As with a number of tools that are add-ons to other components, its overall usefulness might seem limited if you are building your stored procs either using testing patterns …