Jump to content

ObjCreate("Outlook.Application")


Recommended Posts

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

 

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...