Creating applications that use the Microsoft Agent is actually a lot simpler than it sounds. With just a little work, you can create an Outlook macro to read information about incoming e-mails as they are received.
Download and unzip this before you continue:
First enter into the VB editor from Outlook by pressing Alt-F11. Add a new
class to the project by right clicking on the project and selecting Insert >
Class. Rename the class CReaderAgent.
Next it is time to add references to the project.
Tools > References
Check "Microsoft Scripting Runtime" and "Microsoft Agent Control 2.0"
When I did this, Microsoft Agent Control 2.0 didn't show up in the list so I
had to browse for agentctl.dll which is probably in c:\windows\msagent
Import the class by selecting File > Import Files and select
CReaderAgent.cls
Next add this code to "This Outlook Session" which already exists in the
project under "Microsft Outlook Objects."
------------------------------------------------
Option Explicit
Private myMailReader As CReaderAgent
' This is called when Outlook first starts
' Here we'll create a new reader
Private Sub Application_Startup()
Set myMailReader = New CReaderAgent
End Sub
' This method is called when new mail arrives
' If the agent isn't created then we'll create one
Private Sub Application_NewMail()
If myMailReader Is Nothing Then
Call Application_Startup
End If
End Sub
' This method is called when Outlook exits
' Destroy our object
Private Sub Application_Quit()
Set myMailReader = Nothing
End Sub
------------------------------------------------
That's all there is to it. The agent will show up next time you get a new
e-mail.
There is one drawback to this tool. Outlook 2000 (with the security patch)
and new versions have a new "security feature" that doesn't allow other
programs to access your address book. This creates a problem for this tool
because when it accesses the "From" field of the MailItem, Outlook brings up
a box asking if you want to grant the program permission. This takes away
from the automatic features most of us desire. However, this tool is still
valuable for people using previous versions of Outlook and more in general
for anyone who wants to learn how easy it is to use Agents.
This code was accepted as a tool on Devhood!
Disclaimer:
By installing this software, you assume complete responsibility for any
damage that may occur to your system or your oldest child. I assume no
liability. Besides, if you tried to sue me you wouldn't get much.
May cause cancer in pregnant
lab rats on rainy days in Arkansas. Violators will be persecuted. Do not
pass Go, do not collect $200, go directly to jail. An apple a day keeps the
doctor away. Caffeine-free (although I am probably not). Look both ways
before crossing the road. Don't put that quarter in your mouth, you don't
know where it's been. Do not use in areas of high radiation. Do not use
while being chased by a rabid African tiger (a healthy one maybe, but not a
rabid one). I am not responsible for any lost or stolen brain cells. And
last, but not least, have fun!