hendrikhe

ObjCreate("Outlook.Application")

6 posts in this topic

#1 ·  Posted

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



#2 ·  Posted

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

#3 ·  Posted

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

#4 ·  Posted

Hmm. Could this work?

$oOApp.Quit

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

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