I am trying to open Outlook using DXL. I have been trying to use the "oleCreateAutoObject" function to open Outlook. I have successfully opened Excel, Word, and Visio using this method but not Outlook. Does anyone know why? Is there a work around? My code is basically the example in the DXL manual after the "oleCreateAutoOject" function. |
Re: Opening Outlook Application
I know almost nothing about OLE, but I did manage to get a handle on an existing Outlook using
string OutlookKeyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\OUTLOOK.exe"
string OutlookValueName = "" // Default
string OutlookPath = getRegistry(OutlookKeyName, OutlookValueName)
print "Outlook path: [" OutlookPath "]\n"
system(OutlookPath)
sleep_(3000) // 3 second wait
OleAutoObj oaoOutlook = oleGetAutoObject("Outlook.Application")
|
Re: Opening Outlook Application llandale - Tue Jul 20 17:06:06 EDT 2010
I know almost nothing about OLE, but I did manage to get a handle on an existing Outlook using
string OutlookKeyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\OUTLOOK.exe"
string OutlookValueName = "" // Default
string OutlookPath = getRegistry(OutlookKeyName, OutlookValueName)
print "Outlook path: [" OutlookPath "]\n"
system(OutlookPath)
sleep_(3000) // 3 second wait
OleAutoObj oaoOutlook = oleGetAutoObject("Outlook.Application")
Thanks. |
Re: Opening Outlook Application HiLbiLy - Wed Jul 21 07:13:34 EDT 2010
I guess the not so obvious thing is, that the outlook api works well without an explorer window (excel and word do not). You need to explicitly create an explorer tell Outlook to show an explorer window.
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myExplorer = myOlApp.Explorers.Add(myNms.GetDefaultFolder(olFolderInbox), olFolderDisplayNormal)
myExplorer.Activate
OleAutoObj oaoOutlook = oleCreateAutoObject("Outlook.Application")
OleAutoObj myExplorers
OleAutoObj myExplorer
OleAutoObj myNamespace
OleAutoObj myFolder
OleAutoArgs args = create()
put(args, "MAPI")
print "5 " oleMethod (oaoOutlook, "GetNamespace", args, myNamespace)
clear args
// Get a handle to the inbox folder
put(args, 6) // olFolderInbox
print "4 " oleMethod (myNamespace, "GetDefaultFolder", args, myFolder)
// Create an explorer for the inbox
clear args
put(args, myFolder)
put(args, 0) // olFolderDisplayNormal
// Get the Explorers collection
print "3 " oleGet (oaoOutlook, "Explorers", myExplorers)
print "2 " oleMethod (myExplorers, "Add", args, myExplorer)
print "1 " oleMethod(myExplorer, "Activate")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Opening Outlook Application Mathias Mamsch - Wed Jul 21 11:58:44 EDT 2010
I guess the not so obvious thing is, that the outlook api works well without an explorer window (excel and word do not). You need to explicitly create an explorer tell Outlook to show an explorer window.
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myExplorer = myOlApp.Explorers.Add(myNms.GetDefaultFolder(olFolderInbox), olFolderDisplayNormal)
myExplorer.Activate
OleAutoObj oaoOutlook = oleCreateAutoObject("Outlook.Application")
OleAutoObj myExplorers
OleAutoObj myExplorer
OleAutoObj myNamespace
OleAutoObj myFolder
OleAutoArgs args = create()
put(args, "MAPI")
print "5 " oleMethod (oaoOutlook, "GetNamespace", args, myNamespace)
clear args
// Get a handle to the inbox folder
put(args, 6) // olFolderInbox
print "4 " oleMethod (myNamespace, "GetDefaultFolder", args, myFolder)
// Create an explorer for the inbox
clear args
put(args, myFolder)
put(args, 0) // olFolderDisplayNormal
// Get the Explorers collection
print "3 " oleGet (oaoOutlook, "Explorers", myExplorers)
print "2 " oleMethod (myExplorers, "Add", args, myExplorer)
print "1 " oleMethod(myExplorer, "Activate")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Opening Outlook Application
Hello,
//https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14487162�
//https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14488816�
//"c:\program files (x86)\microsoft office\office14\outlook.exe" /nopreview
pragma runLim, 0
const string gl_OleOutlookApp = "Outlook.Application" // Windows recognizes this as a running Outlook
if (null oleGetAutoObject(gl_OleOutlookApp))
{
string OutlookKeyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\OUTLOOK.exe"
string OutlookValueName = "" // Default
string OutlookPath = getRegistry(OutlookKeyName, OutlookValueName)
//print "Outlook path: [" OutlookPath "]\n"
system(OutlookPath)
}
bool fOleOK( string CreateItem, To)
{
bool ret = false
if(null CreateItem) { ret = true }
else{errorBox(To ": " CreateItem)}
return (ret)
}
//******************************
bool fEmailCreateOutlookMail(bool DoSend, string SendTo, SendCC, SendBCC, Subject, Body)
{ // Create the Email message which requires that Outlook.exe is running.
// SendTo, SendCC, and SendBCC should be valid Email addresses separated by semi-colons;.
// Send the Message when DoSend, otherwise just display it.
bool Result = false
OleAutoObj oaoMessage = null
OleAutoObj oaoOutlook = oleGetAutoObject(gl_OleOutlookApp)
if (null oaoOutlook)
{
fOleOK("Outlook not running", "GetOutlook") // Log Error
return(false)
}
OleAutoArgs autoArgs = create()
clear(autoArgs)
put(autoArgs, 0) // 0 is Outlook's symbolic constant for mail item
if(fOleOK(oleMethod(oaoOutlook, "CreateItem", autoArgs, oaoMessage), "CreateItem") and
fOleOK(olePut(oaoMessage, "To", SendTo), "To") and
fOleOK(olePut(oaoMessage, "CC", SendCC), "CC") and
fOleOK(olePut(oaoMessage, "BCC", SendBCC), "BCC") and
fOleOK(olePut(oaoMessage, "Subject", Subject), "Subject") and
fOleOK(olePut(oaoMessage, "Body", Body), "Body")
)
{ // Message created OK. Send or just Show it
if (DoSend)
Result = fOleOK(oleMethod(oaoMessage, "Send"), "Send")
else Result = fOleOK(oleMethod(oaoMessage, "Display"), "Display")
}
else Result = false
delete(autoArgs)
return(Result)
} // end fEmailCreateOutlookMail()
fEmailCreateOutlookMail(false,"SendTo@ABC.com",null,null,"Subject","Body")
|
Re: Opening Outlook Application Mathias Mamsch - Wed Jul 21 11:58:44 EDT 2010
I guess the not so obvious thing is, that the outlook api works well without an explorer window (excel and word do not). You need to explicitly create an explorer tell Outlook to show an explorer window.
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myExplorer = myOlApp.Explorers.Add(myNms.GetDefaultFolder(olFolderInbox), olFolderDisplayNormal)
myExplorer.Activate
OleAutoObj oaoOutlook = oleCreateAutoObject("Outlook.Application")
OleAutoObj myExplorers
OleAutoObj myExplorer
OleAutoObj myNamespace
OleAutoObj myFolder
OleAutoArgs args = create()
put(args, "MAPI")
print "5 " oleMethod (oaoOutlook, "GetNamespace", args, myNamespace)
clear args
// Get a handle to the inbox folder
put(args, 6) // olFolderInbox
print "4 " oleMethod (myNamespace, "GetDefaultFolder", args, myFolder)
// Create an explorer for the inbox
clear args
put(args, myFolder)
put(args, 0) // olFolderDisplayNormal
// Get the Explorers collection
print "3 " oleGet (oaoOutlook, "Explorers", myExplorers)
print "2 " oleMethod (myExplorers, "Add", args, myExplorer)
print "1 " oleMethod(myExplorer, "Activate")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hi
OleAutoObj vbaAppInit(string sApp) {
OleAutoObj oleApp = oleGetAutoObject(sApp);
if (oleApp == null) {
oleApp = oleCreateAutoObject(sApp);
}
if (oleApp == null) {
print "The user does not have a " sApp " installation");
}
return oleApp;
}
OleAutoObj objOutlook = vbaAppInit("Outlook.Application");
|
Re: Opening Outlook Application SystemAdmin - Thu Feb 28 17:43:01 EST 2013
Hello,
//https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14487162�
//https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14488816�
//"c:\program files (x86)\microsoft office\office14\outlook.exe" /nopreview
pragma runLim, 0
const string gl_OleOutlookApp = "Outlook.Application" // Windows recognizes this as a running Outlook
if (null oleGetAutoObject(gl_OleOutlookApp))
{
string OutlookKeyName = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\OUTLOOK.exe"
string OutlookValueName = "" // Default
string OutlookPath = getRegistry(OutlookKeyName, OutlookValueName)
//print "Outlook path: [" OutlookPath "]\n"
system(OutlookPath)
}
bool fOleOK( string CreateItem, To)
{
bool ret = false
if(null CreateItem) { ret = true }
else{errorBox(To ": " CreateItem)}
return (ret)
}
//******************************
bool fEmailCreateOutlookMail(bool DoSend, string SendTo, SendCC, SendBCC, Subject, Body)
{ // Create the Email message which requires that Outlook.exe is running.
// SendTo, SendCC, and SendBCC should be valid Email addresses separated by semi-colons;.
// Send the Message when DoSend, otherwise just display it.
bool Result = false
OleAutoObj oaoMessage = null
OleAutoObj oaoOutlook = oleGetAutoObject(gl_OleOutlookApp)
if (null oaoOutlook)
{
fOleOK("Outlook not running", "GetOutlook") // Log Error
return(false)
}
OleAutoArgs autoArgs = create()
clear(autoArgs)
put(autoArgs, 0) // 0 is Outlook's symbolic constant for mail item
if(fOleOK(oleMethod(oaoOutlook, "CreateItem", autoArgs, oaoMessage), "CreateItem") and
fOleOK(olePut(oaoMessage, "To", SendTo), "To") and
fOleOK(olePut(oaoMessage, "CC", SendCC), "CC") and
fOleOK(olePut(oaoMessage, "BCC", SendBCC), "BCC") and
fOleOK(olePut(oaoMessage, "Subject", Subject), "Subject") and
fOleOK(olePut(oaoMessage, "Body", Body), "Body")
)
{ // Message created OK. Send or just Show it
if (DoSend)
Result = fOleOK(oleMethod(oaoMessage, "Send"), "Send")
else Result = fOleOK(oleMethod(oaoMessage, "Display"), "Display")
}
else Result = false
delete(autoArgs)
return(Result)
} // end fEmailCreateOutlookMail()
fEmailCreateOutlookMail(false,"SendTo@ABC.com",null,null,"Subject","Body")
I did find it rather curious that if you start Outlook and then close it; "get" still works and you don't have to "create". -Louie |
Re: Opening Outlook Application llandale - Sat Mar 02 16:59:58 EST 2013 An office application does not really close if you close it. Just in this time, I've closed my outlook and close really did work. May be there is a communication with your exchange or something else is runnig in the background only the dialog disappears. Best regards Wolfgang |
Re: Opening Outlook Application SystemAdmin - Mon Mar 04 02:26:18 EST 2013
|
Re: Opening Outlook Application llandale - Mon Mar 04 12:59:58 EST 2013
Actually I've practial experience by using Word, Excel and Access but not in Outlook. In those programs you actually can start more than one instances. I.E. if the user has an opened word session and you wanted to perform some "internal calculations" it is better to start an additionaly instance. In Office this makes no sense. You can test this by trying to start word several times and checking the result in the task manager. This works. If you try to start more than one outlook, this does not work. So outlook works different and you allways have 0 or 1 running programs. You cannot terminate an applciation by releasing it's handle. The standard rule to terminate an application is oleAplicationObject.Quit and not oleCloseAutoObject. But you might be right. It is possible that outlook is something different in both cases. |
Re: Opening Outlook Application Mathias Mamsch - Wed Jul 21 11:58:44 EDT 2010
I guess the not so obvious thing is, that the outlook api works well without an explorer window (excel and word do not). You need to explicitly create an explorer tell Outlook to show an explorer window.
Set myOlApp = CreateObject("Outlook.Application")
Set myNms = myOlApp.GetNamespace("MAPI")
Set myExplorer = myOlApp.Explorers.Add(myNms.GetDefaultFolder(olFolderInbox), olFolderDisplayNormal)
myExplorer.Activate
OleAutoObj oaoOutlook = oleCreateAutoObject("Outlook.Application")
OleAutoObj myExplorers
OleAutoObj myExplorer
OleAutoObj myNamespace
OleAutoObj myFolder
OleAutoArgs args = create()
put(args, "MAPI")
print "5 " oleMethod (oaoOutlook, "GetNamespace", args, myNamespace)
clear args
// Get a handle to the inbox folder
put(args, 6) // olFolderInbox
print "4 " oleMethod (myNamespace, "GetDefaultFolder", args, myFolder)
// Create an explorer for the inbox
clear args
put(args, myFolder)
put(args, 0) // olFolderDisplayNormal
// Get the Explorers collection
print "3 " oleGet (oaoOutlook, "Explorers", myExplorers)
print "2 " oleMethod (myExplorers, "Add", args, myExplorer)
print "1 " oleMethod(myExplorer, "Activate")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Hi Mathias, That's exactly what I need, but how do I open an email with a certain subject. I do not really understand. regards Micha |