#90392 - 2002-12-08 04:59 PM
outlook send/recieve mail
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Anyone know the COM for send/recieve??
I'm looking to schedule/script COM outlook open, send / recieve, and close.
Not a big deal on a LAN with Exchange, but for dialup/vpn, or smtp configs; this would be used instead of keeping Outlook open and having it's internal scheduling do it.
I think outlook express has a system tray client to do this...
|
|
Top
|
|
|
|
#90395 - 2002-12-08 05:06 PM
Re: outlook send/recieve mail
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Nothing there on COM for Outlook.
Lots of configuring outlook Lots of generic COM and ADSI How-To links
|
|
Top
|
|
|
|
#90397 - 2002-12-08 05:13 PM
Re: outlook send/recieve mail
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
that is almost it...
but it those basically create and send email... but rely on Outlook's config to determine when it actually goes.
I need to do something more like: $Root = CreateObject("Outlook.Application") $MailItem = $Root.CreateItem(0) $MailItem.Send
but without actually creating the mail message... and then force outlook to send/recieve
|
|
Top
|
|
|
|
#90399 - 2002-12-08 05:30 PM
Re: outlook send/recieve mail
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rad,
How about..
$Root.Send
This needs to be an event.
This appears in the Project Explorer of Outlook.
Kent
|
|
Top
|
|
|
|
#90400 - 2002-12-08 05:53 PM
Re: outlook send/recieve mail
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
so this should do it??
code:
$Root = CreateObject("Outlook.Application") $Root.Send $Root = ""
cool, got to love tight scripts
|
|
Top
|
|
|
|
#90401 - 2002-12-08 10:00 PM
Re: outlook send/recieve mail
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Rad,
I think so.
Really, what you are looking for is to instantiate a session of Outlook, check the account and close?
If you are going to use your code, you need to "tidy up" the COM Object. This is per the manual.
code:
$Root = CreateObject("Outlook.Application") $Root.Send $Root = "" $Root = 0
C'ya,
Kent
|
|
Top
|
|
|
|
#90404 - 2002-12-08 10:37 PM
Re: outlook send/recieve mail
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
that what I was saying...
quote: Anyone know the COM for send/recieve??
I'm looking to schedule/script COM outlook open, send / recieve, and close.
I have the COM for Getobject and quit... It's the pesky command in the middle...
|
|
Top
|
|
|
|
#90406 - 2002-12-10 09:41 AM
Re: outlook send/recieve mail
|
Anonymous
Anonymous
Unregistered
|
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 ;************************************************************
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 823 anonymous users online.
|
|
|