Page 1 of 1 1
Topic Options
#207757 - 2013-09-17 04:45 PM $Root = CreateObject("Outlook.Application") does not launch outlook 2010
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
If I have outlook 2010 open, my kix script work. However, if outlook is closed,
 Code:
$Root = CreateObject("Outlook.Application")

will not launch outlook to send the emails.
Any ideas?
Thanks

Top
#207758 - 2013-09-17 06:28 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
because that does not open outlook, it just creates the com-object so kixtart can work with it.
_________________________
!

download KiXnet

Top
#207761 - 2013-09-17 07:25 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Lonkero]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
what does open outlook?
Top
#207762 - 2013-09-17 08:06 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you need to look at outlook/office com reference.
I would guess something like $root.visible = 1 would do it.
_________________________
!

download KiXnet

Top
#207764 - 2013-09-17 11:14 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Lonkero]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
I have looked everywhere and cannot find the command to launch outlook 2010 in kix.
This is what I have:
 Code:
	;main program loop

	$rc = SetOption("NoMacrosInStrings","On")
	$rc = SetOption("NoVarsInStrings","On")

	
	; create outlook application
	$Root = CreateObject("Outlook.Application")
        
	$MailItem = $Root.CreateItem(0)
	$MailItem.Importance = 1
	; - 2 high importance
	; - 1 normal importance
	; - 0 low importance
	$MailItem.Subject = "This is the subject"
	$MailItem.Sender = "namesender@mail.net"
	$MailItem.To = "nameto@mail.net"
	$MailItem.CC = "namecc@mail.net"
	$MailItem.Body = "This is the body"

;EndIf
$MailItem.Send
$Root = 0


If anyone can supply the command to launch and where it will go in this script I would really appreciate it!

Top
#207767 - 2013-09-18 07:17 AM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
weeeelll,

normally you need to do several things before showing an office product with content to a user .. never had to do this with Outlook, but I would guess you'll have to use some of these methods/properties:

.Visible (or .Show* ?)
.UserControl (enable/disable)
_________________________



Top
#207768 - 2013-09-18 07:22 AM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
yeah, um, that what the Lonk said basically.

Open Outlook, hit ALT+F11 ... experiment there, or look for the keywords in Object Browser under Application.

Kent Dyer did much with Outlook in the time, but he seems to be retired ;\)
_________________________



Top
#207771 - 2013-09-18 03:35 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Jochen]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
The problem I am running into is that the above code will NOT send the e-mails unless outlook is open.
Apparently the script needs to open outlook and then close outlook. This is a scheduled job with no user intervention.

When I run the script, outlook.exe runs in the task manager, but does not do the e-mailing.

Just FYI - I am fairly new to kix scripting and I am having to convert old kix scripts to new ones.

Top
#207772 - 2013-09-18 03:58 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
In all the examples I found googling, it seems there is one more line that is needed. Right after your $root= line, try adding:

$ns = $Root.getNamespace("MAPI")
_________________________
(... better days ahead)

Top
#207773 - 2013-09-18 04:00 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
I got it!!

 Code:
	$Root = CreateObject("Outlook.Application")
	$Session = $Root.GetNamespace("MAPI")
	$DefaultProfile = Outlook
	$Session.Logon($DefaultProfile)	
	$Folder = $Session.GetDefaultFolder(olFolderInbox)
	$Folder.Display


I found the info at
Launch outlook 2010

Now the script launches outlook, e-mails as necessary and closes outlook!

 Code:
	;main program loop

	$rc = SetOption("NoMacrosInStrings","On")
	$rc = SetOption("NoVarsInStrings","On")

	
	; create outlook application
	
	$Root = CreateObject("Outlook.Application")
	$Session = $Root.GetNamespace("MAPI")
	$DefaultProfile = Outlook
	$Session.Logon($DefaultProfile)	
	$Folder = $Session.GetDefaultFolder(olFolderInbox)
	$Folder.Display

	$MailItem = $Root.CreateItem(0)
	$MailItem.Importance = 1
	; - 2 high importance
	; - 1 normal importance
	; - 0 low importance
	$MailItem.Subject = "Subject Text"
	$MailItem.Sender = "sender@mail.net"
	$MailItem.To = "to@mail.net"
	$MailItem.CC = "cc@mail.net"
	$MailItem.Body = "Body of the Message"

;EndIf
$MailItem.Send
$Root = 0

Top
#207776 - 2013-09-18 06:46 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Karon]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
see. \:\)
and right in time not to be told the correct answer posted by Allen ;\)
_________________________
!

download KiXnet

Top
#207780 - 2013-09-18 08:09 PM Re: $Root = CreateObject("Outlook.Application") does not launch outlook 2010 [Re: Lonkero]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Thanks guys!!!
Top
Page 1 of 1 1


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

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.072 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

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