Jump to content
hendrikhe

ObjCreate("Outlook.Application")

Recommended Posts

hendrikhe

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

 

 

Func 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

 

Share this post


Link to post
Share on other sites
Floops

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

 

Share this post


Link to post
Share on other sites
hendrikhe

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

Share this post


Link to post
Share on other sites
Floops

Hmm. Could this work?

$oOApp.Quit

 

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
hendrikhe

Thanks for the hint, To be honest I wanted to evade to work with registry keys, I am always so unlucky with them :P

 

$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

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×