hendrikhe Posted May 2, 2017 Share Posted May 2, 2017 Hello AutoIt Community, I am trying to send an email with a file attached. It works fine if Outlook is configured, but I am having issues when Outlook is not configured. The Outlook configuration Wizard keeps popping up after cancelling it (5 times) until it gives up. I would like to exit this funtion if Outlook is not configured. Tried with "If NOT @error Then" but it keeps starting the Outlook Setup Wizard expandcollapse popupFunc CreateMailItem() Local $olMailItem = 0 Local $olFormatRichText = 3 Local $olImportanceNormal = 1 $oOApp = ObjCreate("Outlook.Application") If NOT @error Then $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .To = ("test@test.com") .Subject = "" .Body = "" .Attachments.Add(@MyDocumentsDir & '\test\' & "test.txt") .Importance = $olImportanceNormal .Display EndWith Else MsgBox($MB_SYSTEMMODAL, "", "Could not find Outlook") EndIf EndFunc Link to comment Share on other sites More sharing options...
Floops Posted May 2, 2017 Share Posted May 2, 2017 Maybe you could try checking if the configuration wizard popus up by using If WinExists("") Then ; Put name of configuration wizard here ; Do something here Endif Link to comment Share on other sites More sharing options...
hendrikhe Posted May 2, 2017 Author Share Posted May 2, 2017 Yeah, had this idea, but if I choose to close this Window for example, it will keep popping up a couple of times. I need somehow to cancel ObjCreate("Outlook.Application") if Outlook is not configured Link to comment Share on other sites More sharing options...
Floops Posted May 2, 2017 Share Posted May 2, 2017 Hmm. Could this work? $oOApp.Quit Link to comment Share on other sites More sharing options...
water Posted May 2, 2017 Share Posted May 2, 2017 You need to determine if Outlook has been configured. Search Google how to. It's either a file or a Regkey. I'm on vacation so can't check. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
hendrikhe Posted May 3, 2017 Author Share Posted May 3, 2017 Thanks for the hint, To be honest I wanted to evade to work with registry keys, I am always so unlucky with them $Outlookexist2007 = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Profiles",1) If NOT @error Then $Outlookexist2007 = 1 EndIf $Outlookexist2010 = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Profiles",1) If NOT @error Then $Outlookexist2010 = 1 EndIf $Outlookexist2013 = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles",1) If NOT @error Then $Outlookexist2013 = 1 EndIf $Outlookexist2016 = RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles",1) If NOT @error Then $Outlookexist2016 = 1 EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now