Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OUTLOOK automation not work in EXE mode

Status
Not open for further replies.

krish77

IS-IT--Management
Oct 15, 2002
4
0
0
Hello, i have included following scripts in my program

oOutLookObject = CreateObject('Outlook.Application')
oEmailItem = oOutLookObject.CreateItem(MAILITEM)
WITH oEmailItem
.Recipients.Add('moe@3stooges.com')
.Subject = 'Automation sample'
.Importance = IMPORTANCENORMAL
.Body = 'This is easy!'
.Attachments.Add('c:\mydir\sample.txt')
.Send
ENDWITH

and built the project to create win32 exe/com server (exe). The exe does not run properly but when it is run through "execute selection" under command windown or as a program (do "program") it is executed properly. What should be done to run "exe" properly ?

Thanks
Murali

 
What error is reported. From that code snippet alone I see defintion of constants missing (MAILITEM, IMPORTANCENORMAL), but that would affect both running the code snippet in command window or as compiled exe, so I don't see a reason.

I found sometimes the creation of the object reference to office.application objects finishes too early, asxynchronous to the real process/object you reference, with the effect, that adressing a method or property of the oOutlookObject in your case will fail with an error. Simply Try DOEVENTS FORCE right after CreateObject('Outlook.Application') to wait for all related events creating the outlook object before using CreateItem(). But in fact this too is something affecting both executing from within the IDE and compiled code.

It's worth giving a try, but I don't see a real reason the code only fails compiled.

Bye, Olaf.
 
Hello OlafDoschke

Thank u very much . It worked.
Constants are defined (MAILITEM ..) but i did not post here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top