Not sure if this helps. Ben had sent it to me a while back. Guess he never got around to posting it here himself.
code:
;************************************************************
;** Script: MS-Outlook automation sample script using UDF's
;** Version: 0.1
;** Created: Saturday October 20, 2001
;** File: OutlookItemsUDF.kix
;**
;** Author: Ben Burnett
;** E-mail: BenBurnett@telusplanet.net
;**
;** Requirements:
;**
;** KiXtart 2001 BETA
;** Office2K
;**
;** Purpose / Comments:
;**
;** Makes a new MS-Outlook item
;** - Only tested on Office2K using Win2K
;**
;** Refrence Material used:
;**
;** 1) Microsoft Office 2000 Language Reference
;** 2) msoutl9.IDL (MS-Outlook 2000) - Generated with
;** OLE/COM Object viewer
;**
;** Known problems:
;**
;** * [FIXED] MS-Outlook stays resident even if it
;** explicitly told to Quit... what a F<censored>KING
;** piss off ;)
;************************************************************
;************************************************************
; Declare some global variables
;
; Simple boolean variables
;
$TRUE = 1
$FALSE = 0
;
; Enable debugging
;
If $DEBUG = $TRUE
DEBUG ON
EndIf
;
; Outlook items that can be created with this script
;
$intMailItem = 0
$intAppointItem = 1
$intContactItem = 2
$intTaskItem = 3
$intJournalItem = 4
$intNoteItem = 5
$intPostItem = 6
$intDistListItem = 7 ; Create a new distribution list (not in my docs)
;
; Ugly globals
;
Dim $objMyNote ; the item were creating
Dim $strMessage ; general purpose variable to hold messages
;************************************************************
; Main Script start
:MAIN
;
; Script Start
;
; Do some standard init.
$= SetConsole ( "HIDE" )
Break on
FlushKB
Dim $objApp
; Create our application object
$objApp = CreateApplicationObject ()
If 0 = $objApp
$strMessage = "ERROR: Failed to create MS-Outlook object"
ReportError ( $strMessage )
Exit ( 0 ) ; error
EndIf ; If 0 = $objApp
If $FALSE <> $objApp ; ok to continue
Dim $objMyNote
; Create the new MS-Outlook Note item
$objMyNote = CreateNoteItem ( $objApp, "Hello World!" )
If 0 = $objMyNote
$strMessage = "ERROR: Failed to create MS-Outlook note"
ReportError ( $strMessage )
Exit ( 0 ) ; error
EndIf ; If 0 = $objMyNote
; Display the new note
$objMyNote.Display ( 0 )
; sit and wait for MS-Outlook to finish doing its thing...
WaitForOutlook ( $objApp )
; close MS-Outlook
$objApp.Quit
EndIf ; If $FALSE <> $objApp
Exit ; done...
;************************************************************
; Create an MS-Outlook item
;************************************************************
;
;************************************************************
Function CreateApplicationObject ()
; Create an MS-Outlook application object
;
; NOTE: If you know for sure that Outlook 2000 installed you could
; use: "Outlook.Application.9"
;
$CreateApplicationObject = CreateObject ( "Outlook.Application" )
EndFunction ; return to caller
;************************************************************
; Create an MS-Outlook item
Function CreateNoteItem ( $objApp, $strText )
Dim $objMyNote
; Create the new MS-Outlook note item
$objMyNote = $objApp.CreateItem ( $intNoteItem )
If 0 = $objMyNote
; return the note object
$CreateNoteItem = 0 ; error
Return ; done...
EndIf ; If 0 = $objMyNote
; Set the note's text body
$objMyNote.Body = $strText
; return the note object
$CreateNoteItem = $objMyNote
EndFunction ; return to caller
;************************************************************
; Function to wait till MS-Outlook is done
Function WaitForOutlook ( $objApp )
;************************************************************
;
; The next section of code retrieves the application's Inspectors
; collection object. Using this object we can determine how many
; item windows are currently open, in our case it will be 1. Once we
; have a reference to the inspector object we simply wait (Loop)
; till its 'Count' property decrements to zero.
;
; DEF'N: An Inspector object represents the window in which an
; item is displayed. Thus MS-Outlook's Inspectors collection
; contains a list of all the open/visible MS-Outlook windows.
;
;************************************************************
;
; WARNING: Be carefull doing this, the user might be reading their
; email and the script would loop indefinitly... or till it
; crashes anyway ;)
;
;************************************************************
; Wait till Outlook's Inspectors collection has no items in it
While $objApp.Inspectors.Count > 0 And @ERROR = 0
; ...just wait...
Loop ; While $objApp.Inspectors.Count > 0 And @ERROR = 0
EndFunction ; return to caller
;************************************************************
; Show the user an error, will disappear after 2 sec.
Function ReportError ( $strMessage ) ;Nothing
; Format the message
Dim $strErrMsg
$strErrMsg = $strMessage + Chr ( 10 ) + "- " + @SERROR
; Show the error to the user
$ = MessageBox ( $strErrMsg, "ERROR!", 0, 2 )
; Ignore return value, if this fails... look out
; your window, the sky should be falling ;)
EndFunction ; return to caller
;************************************************************
;** EOF
;************************************************************