Page 1 of 1 1
Topic Options
#90392 - 2002-12-08 04:59 PM outlook send/recieve mail
Radimus Moderator Offline
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...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90393 - 2002-12-08 05:01 PM Re: outlook send/recieve mail
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Rad,
Didn't Kent just post something like that to the FAQ?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#90394 - 2002-12-08 05:01 PM Re: outlook send/recieve mail
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
rad,
doesn't any of those senders in faq help?
_________________________
!

download KiXnet

Top
#90395 - 2002-12-08 05:06 PM Re: outlook send/recieve mail
Radimus Moderator Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90396 - 2002-12-08 05:08 PM Re: outlook send/recieve mail
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Topic: How do I send e-mail from KiXtart? (SMTP)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#90397 - 2002-12-08 05:13 PM Re: outlook send/recieve mail
Radimus Moderator Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90398 - 2002-12-08 05:19 PM Re: outlook send/recieve mail
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, you mean that connection...
doh, not sending mail but syncing with server...
_________________________
!

download KiXnet

Top
#90399 - 2002-12-08 05:30 PM Re: outlook send/recieve mail
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#90400 - 2002-12-08 05:53 PM Re: outlook send/recieve mail
Radimus Moderator Offline
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 [Big Grin]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90401 - 2002-12-08 10:00 PM Re: outlook send/recieve mail
Kdyer Offline
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. [Big Grin]

code:
$Root = CreateObject("Outlook.Application")
$Root.Send
$Root = ""
$Root = 0

C'ya,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#90402 - 2002-12-08 10:32 PM Re: outlook send/recieve mail
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I think you want something along these lines:
code:
$Root = CreateObject("Outlook.Application")
$Root.SendAndReceive
$NewMailCount=$Root.NumberNewMail
$root.quit

However, don't know what COM functions Outlook offers.

[ 08. December 2002, 22:35: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#90403 - 2002-12-08 10:36 PM Re: outlook send/recieve mail
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, I quess will hit your suggestion with some correction:
code:
$Root = CreateObject("Outlook.Application")$Root.Send
$Root.quit

the reason for quitting is that outlook is active server and it will keep going on if you don't quit it.

you may test with word and some good sized document like manual.
it will keep hitting processor usage 99% until you kill it.
variable release has no effect on it and it will anyway happen once script exits.
_________________________
!

download KiXnet

Top
#90404 - 2002-12-08 10:37 PM Re: outlook send/recieve mail
Radimus Moderator Offline
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...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#90405 - 2002-12-08 10:55 PM Re: outlook send/recieve mail
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dunno, there is outlook.syncobject....
_________________________
!

download KiXnet

Top
#90406 - 2002-12-10 09:41 AM Re: outlook send/recieve mail
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
#90407 - 2003-08-25 11:12 AM Re: outlook send/recieve mail
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
listing some problems with this script:
1) setconsole can't be hide as that screws wkix32.exe up.
2)break on shouldn't be stated as it's always off with wkix32.exe and in some versions has opposite effect due to bug.
3)wait for outlook is loop which when running will hog up the cpu and thus delay everything else in the computer, even the outlook. problem solved with simple "sleep 0.2"
4) createapplication object should indeed do with .9 and then check if error occured. as this is purely for off2k, this is not an option
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 823 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.065 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org