Jump to content

OutlookEX UDF - Help & Support (IV)


Recommended Posts

Grrr, IT in this company makes me crazy.

I'm sitting at the same pc, outlook itself worked like yesterday, I'm running the same test snippet and today sending the mail with _OL_Wrapper_SendMail() returns an error. _OL_ErrorNotify(1) says:

Quote

COM Error Encountered in test7.au3
OutlookEX UDF version = 1.3.6
@AutoItVersion = 3.3.14.2
@AutoItX64 = 1
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_10
Scriptline = 4350
NumberHex = 80070057
Number = -2147024809
WinDescription = Falscher Parameter. (Wrong parameter)
Description = 
Source = 
HelpFile = 
HelpContext = 
LastDllError = 0

I'm not aware of doing or having done anything differently today then yesterday. What could that "wrong parameter" be?

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to post
Share on other sites
  • Replies 565
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Fixed in version 1.3.3.1 of the UDF I uploaded today

I've done something like this before, and if I remember correctly, the sent email object is no longer valid after it has been sent. To solve it, I searched the sent email folder for the subject of the

Version 1.7.0.0 of the UDF has been released. Now you get a help file that looks like the AutoIt help. Please test before using in production! For download please see my signature.

Posted Images

The sent mail is saved in folder "Sent items"  ("Gesendete Objekte").
You could use the event driven approach described in example script _OL_Example_ItemAdd_Event.au3
The object returned by _OL_Wrapper_SendMail is no longer valid to access the moved sent mail item. That's what causes your problem.
Another approach is to search the Sent Items folder for the sent mail.

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 post
Share on other sites
Posted (edited)

I've done something like this before, and if I remember correctly, the sent email object is no longer valid after it has been sent. To solve it, I searched the sent email folder for the subject of the just sent email (I think I specified within the last minute as well) and copied that object instead.

Edit: And now I see there's another page of replies :oops:

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager

Link to post
Share on other sites
  • 1 month later...

Good morning,

At work, I frequently use Microsoft Word's Mail Merge (which does not support BCC or attachments) to send emails to a couple hundred people. I aim to use this wonderful UDF to add a BCC email and attachments to these emails. I can get the emails to sit in my outbox by setting Outlook to Work Offline, so I'm trying to put something together that will loop through all the emails in my outbox and give each a BCC address and selected attachments. Below is what I have so far, but I'm not clever enough today to fix the Update_Outbox() function, and I was hoping someone in here was willing to help. I have outlined what I think I should try to do.

AutoItSetOption("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Global $BCC_Address
Global $Email_Attachment
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstants.au3>
#include <OutlookEx_Base.au3>
#include <OutlookEx.au3>

#Region ;GUI
Global $Email_Helper_GUI = GUICreate("", 311, 58)
    GUISetBkColor(0xCCCCCC)
    GUISetFont(14)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Email_Helper_Events")
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "Email_Helper_Events")
    GUISetOnEvent($GUI_EVENT_RESTORE, "Email_Helper_Events")
Global $GUI_Label_BCC = GUICtrlCreateLabel("BCC email:",5,5,90,22)
Global $BCC_Address_Field = GUICtrlCreateInput("",100,5,206,22)
    GUICtrlSetFont(-1,12)
Global $GUI_Select_Attachment_Button = GUICtrlCreateButton("Select Attachment",3,30,150,24)
    GUICtrlSetFont(-1,12)
    GUICtrlSetOnEvent(-1,"Select_Attachment")
Global $GUI_Update_Outbox_Button = GUICtrlCreateButton("Update Outbox",158,30,150,24)
    GUICtrlSetFont(-1,12)
    GUICtrlSetOnEvent(-1, "Update_Outbox")
    GUISetState(@SW_SHOW, $Email_Helper_GUI)
#EndRegion

While 1
   Sleep(10)
WEnd

Func Email_Helper_Events() 
   Select
      Case @GUI_CtrlId = $GUI_EVENT_CLOSE
         Exit
      Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
      Case @GUI_CtrlId = $GUI_EVENT_RESTORE
   EndSelect
EndFunc

Func Select_Attachment()
    $Email_Attachment = FileOpenDialog("Select Attachment", @MyDocumentsDir,"All (*.*)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT))
    If @error Then ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
        FileChangeDir(@ScriptDir) 
    Else
        FileChangeDir(@ScriptDir) 
        MsgBox($MB_SYSTEMMODAL, "", "You chose the following file(s):" & @CRLF & $Email_Attachment)
    EndIf
EndFunc

Func Update_Outbox()
    $BCC_Address = GUICtrlRead($BCC_Address_Field)
    Global $oOL = _OL_Open()                                            ; Connect to Outlook
    Global $Outlook_Outbox = _OL_FolderAccess($oOL, $olFolderOutbox)    ; Access the Outbox
;~  For ???? to ????
;~  ????????????? = _OL_ItemRecipientAdd($oOutlook, $Each_Email_In_Outbox, Default, $olBCC, $BCC_Address)
;~  ????????????? = _OL_ItemAttachmentAdd($oOutlook, $Each_Email_In_Outbox, Default, $Email_Attachment)
;~  Next
;~  MsgBox(1,"OutBox Update Complete", "The OutBox has been updated.")
;~  _OL_Close($oOutlook)
EndFunc

I appreciate any guidance. Thank you.

 

Link to post
Share on other sites
18 hours ago, jiataifeng said:

I would like to get all the appointments information from ics files but ics files are hard to parse. Is it possible to parse ics file to xml? Is there a tool can do so? Thanks.

You could have a look at function _OLT_iCal_VEvent_Import in my OutlookTools UDF (for download please see my signature below).
You won't get an XML file and the function has its limitation (see the Wiki) but the parsed ICS file gets returned as an array.
Set parameter $iDebug = $iOLT_DebugCreateOff then no Outlook item will be created from the ICS file, just the array will be returned.

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 post
Share on other sites
2 hours ago, baconaise said:

At work, I frequently use Microsoft Word's Mail Merge ...

Seems there are tools available to extend the functions of Mail Merge:

Or you could grab the Outlook event to modify a mail before it gets sent.
Please check example script _OL_Example_ItemSend_Event.au3 from the OutlookEX UDF (for download please see my signature).

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 post
Share on other sites
3 hours ago, water said:

Seems there are tools available to extend the functions of Mail Merge:

OMMA gave me the idea for this, but neither of those options allow adding a BCC email. Work requires I log the emails I send by BCCing an email address. I am trying to automate both the attachments and the BCCing.

Link to post
Share on other sites

It appears my current hurdle is _OL_FolderAccess giving the error "Error accessing Outbox. @error = 4, @extended = 1" when I try to run this:

Func Update_Outbox()
    Global $oOL = _OL_Open()                                            
    Global $Outlook_Outbox = _OL_FolderAccess($oOL, $olFolderOutbox)

Which means it can't find $olFolderOutbox.

I thought that part would work because I found $olFolderOutbox in OutlookEX_Base.au3 (which I included in the script). Any idea why it can't find the outbox?

Link to post
Share on other sites

Your syntax is wrong. Should be: 

Global $Outlook_Outbox = _OL_FolderAccess($oOL, "", $olFolderOutbox)

 

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 post
Share on other sites

Another approach:
Wait for emails to be sent by Outlook.

  • When the subject starts with the mailberge marker (selected by you) BCC will be set an the attachment will be added.
  • Else the mail will just be sent

With this approach there is no need to take Outlook offline.

#include <OutlookEX.au3>

; *****************************************************************************
; Example Script
; Handle Outlook event when a new item is being sent.
; This example script checks for mail items and changes the subject before the mail is
; being sent.
; This script loops until Shift-Alt-E is pressed to exit.
; *****************************************************************************
HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script
MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!")

Global $oOL = _OL_Open()
Global $oEvent = ObjEvent($oOL, "_oItems_")

Global $sBCC = "Jon.Doe@gmx.com"
Global $sAttachment = @ScriptFullPath
Global $sMarker = "<MailMerge>" ; Marker
While 1
    Sleep(50)
WEnd

; ItemSend event - https://docs.microsoft.com/en-us/office/vba/api/outlook.application.itemsend
Volatile Func _oItems_ItemSend($oItem, $bCancel)
    #forceref $bCancel
    $bCancel = False ; If you do not want to send the item then set $bCancel to True
    If $oItem.Class = $olMail Then
        If StringLeft($oItem.Subject, StringLen($sMarker) = $sMarker Then     ; Marker to identify mail merge mails found?
            $oItem.Subject = StringMid($oItem.Subject, StringLen($sMarker)+1) ; Remove the marker
            _OL_ItemRecipientAdd($oOL, $oItem, Default, $olBCC, $sBCC)        ; Add the BCC recipient
            _OL_ItemAttachmentAdd($oOL, $oItem, Default, $sAttachment)        ; Add the attachment
            $oItem.Save()
        EndIf
    EndIf
EndFunc   ;==>oItems_ItemSend

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

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 post
Share on other sites
  • 2 weeks later...

I solved all my issues by studying the sample files you included with the thing. I should have read everything before asking a question. What I ended up with was essentially this:

Global $Outlook_Connection = _OL_Open()
Global $Outlook_Outbox = _OL_FolderAccess($Outlook_Connection, "", $olFolderOutbox)
Global $Emails_In_Outlook_Outbox = _OL_ItemFind($Outlook_Connection, $Outlook_Outbox[1], $olMail, "", "", "", "EntryID")

For $iIndex = 1 To $Emails_In_Outlook_Outbox[0][0]
  $Email_In_Focus = $Outlook_Connection.Session.GetItemFromID($Emails_In_Outlook_Outbox[$iIndex][0])
  _OL_ItemRecipientAdd($Outlook_Connection, $Email_In_Focus, Default, $olBCC, $BCC_Address)
  _OL_ItemAttachmentAdd($Outlook_Connection, $Email_In_Focus, Default, $Email_Attachment)
Next

I very much appreciate you making this UDF. This is going to save me upwards of an hour per week.

Edited by baconaise
Clarity
Link to post
Share on other sites

Glad you got your problem solved 😃

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 post
Share on other sites
  • 4 weeks later...

Hi together,

now I use my script on WIN 8 (Microsoft Office Professional Plus 2013) and it works perfect.

I have to change to WIN 10 (Microsoft 365 Apps for Enterprise) and as I tested the script it don´t work anymore. Can you please help?

I downloaded the actual OutlookEx.au3 (OutlookEX 1.7.0.1) and OutlookEX_GUI.au3 (OutlookEX_GUI 1.4.0.0)

$htmlpfad = "U:\C\CO\@ Order Processing\Team Fixed Line Porting\TKG Team\Prävention\AutoIt\kurzfr. Storno\html-Storno.txt"
Local $datei = FileOpen($htmlpfad, 0)
Local $HTML = FileRead($datei)
FileClose($datei)

$HTMLKDDaten = $HTML
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#Rufnummern#",$alleNummern)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#relevante Nummer#",$relevanteNummer)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#Kundennummer#",$Kundennummer_Wert)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#NameVorname#",$KDNachname_Wert & ", " & $KDVorname_Wert & ", " & $Firmenname_Wert)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#StraßeHausnummer#",$Strasse_Wert & " " & $Hausnr_Wert & " " & $HausnrZusatz_Wert)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#PLZOrt#",$PLZ_Wert & " " & $Ort_Wert)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#EKPabg#",$EKPabg_Wert)
$HTMLKDDaten = StringReplace($HTMLKDDaten,"#CarrierCode#",$CarrierCode_Wert)

$oOutlook = ObjGet("", "Outlook.Application")
        
    if $CarrierEMail = "nicht gefunden" Then
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=[AutoIT:ZU PRUEFEN] #abw# weiterversorgen #kurzfristiger Storno# " &   $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        $EMail = "ABW-Clearing-D019@telefonica.com"
    Else
        $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=#abw# weiterversorgen #kurzfristiger Storno# " & $alleNummern & " , " & $relevanteNummer & " , " & $Kundennummer_Wert, "", "SentOnBehalfOfName=ABW-Clearing-D019@telefonica.com")
        $EMail = $CarrierEMail
    EndIf
    
    $EMailCC = "ABW-Clearing-D019@telefonica.com"
        
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $EMail) ; Empfänger wird gesetzt
    _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olCC, $EMailCC) ; CC wird gesetzt
    
    $oItem.display
    $oItem.BodyFormat = $olFormatHTML
    $sBody = $oItem.HTMLBody
    $oItem.HTMLBody = $HTMLKDDaten & $sBody

    $oItem.send

error AutoIt:

"U:\C\CO\@ Order Processing\Team Termination and Cancellation\persönliche Ordner\Nicole Wedtrat\Autoit\ISN AutoIt Studio\Projects\Outlooktest mit DEU.TEFGER.V001584774\Outlooktest_mit_DEU_TEFGER_V001584774.au3" (382) : ==> The requested action with this object has failed.:
$sBody = $oItem.HTMLBody
$sBody = $oItem^ ERROR

 

The creation of the mail works and also the subject is set.

SentOnBehalfOfName does not work: my email-adress is taken instead of ABW-Clearing-D019@telefonica.com
and the whole body is not set (it´s empty)

image.png.dd0991a3651ad9756fb27649be7f9f2e.png

Edited by NolleWed
Link to post
Share on other sites

Cound you please add

_OL_ErrorNotify(2)

at the top of your script so we get more detailed error information?

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 post
Share on other sites

BTW:
SentOnBehalfOfName requires the Displayname not the full Mail-Address. Maybe this is the cause of the problem.

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 post
Share on other sites
33 minutes ago, water said:

Cound you please add

_OL_ErrorNotify(2)

at the top of your script so we get more detailed error information?

 

image.png.5d173f53b5ae0918d315a8f9c9b2454b.png

 

when I click ok, the body comes:

 

image.png.c95836740047261deb956e7aa34397d0.png

 

then I have to kill the script because with each new click on ok a new mail is created

Edited by NolleWed
Link to post
Share on other sites

Might be caused by a group policy as described here.

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 post
Share on other sites
11 hours ago, water said:

Might be caused by a group policy as described here.

That link doesn´t help me. I still don´t know how to solve the problem.

I don´t know how to do this:

image.png.2d49601cc118045ced0f625c2adcf388.png

When I use this testscript the body is filled

#include <OutlookEx.au3>
$oOL = _OL_Open()
_OL_Wrapper_SendMail($oOL, "John Doe", "", "", "Testmail", "<b>Test</b>", "", $olFormatHTML, $olImportanceHigh)
_OL_Close($oOL)

image.png.b4f643dcf20af28ee54b5578ec4fc51d.png

When I use this testscrpit I get an error message

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
  "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "SentOnBehalfOfName=Doe Jane")
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
; Send the mail
_OL_ItemSend($oOL, $oItem)
If @extended = -2147352567 Then _
  MsgBox(16, "OutlookEX UDF - Example Script", "You don't have permission to send the mail on behalf of the specified person!")
_OL_Close($oOL)

image.png.4a00c6d8f373fa7ab4ec6a639942bc53.png

 

Edited by NolleWed
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Cyborg5000
      Can some one please point me why i keep getting the error while the script is in loop:-
      "C:\Program Files (x86)\AutoIt3\Include\OutlookEX.au3" (2443) : ==> Subscript used on non-accessible variable.:
      If Not (IsNumber($iAttachment)) Or $iAttachment < 1 Or $iAttachment > $aAttachments[0][0] Then Return SetError(8, $aAttachments[0][0], 0)
      If Not (IsNumber($iAttachment)) Or $iAttachment < 1 Or $iAttachment > $aAttachments^ ERROR
      My code as below though copied and modified as per need, to get attachments, and other details.
      #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <Array.au3> #include <String.au3> #include <UIAWrappers.au3> #include <GuiEdit.au3> #include <Clipboard.au3> #include <WinAPI.au3> #include <ColorConstants.au3> #include <FontConstants.au3> #include <ProgressConstants.au3> #include <Restart.au3> #include <_IEquerySelectorAll.au3> #include <GuiRichEdit.au3> #include <hiddenDesktopInteract.au3> #include <Date.au3> #include <CUIAutomation2.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> ;Global $oErrorHandler = ObjEvent("Autoit.Error", "ComErrorHandler") FileDelete("D:\attachment\*.*") FileDelete("D:\Email-Details\*.*") FileDelete("D:\Script-temp\*.*") FileDelete("D:\Downloaded-Cert\*.*") FileDelete("D:\LOG\*.*") RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE) ;Global $Errorcomments ;If Not IsDeclared($Errorcomments) Then Global $Errorcomments ; ***************************************************************************** ; Example Script ; Handle Outlook NewmailEX event when a new mail arrives. ; This script loops until Shift-Alt-E is pressed to exit. ; ***************************************************************************** HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script ;MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!") Global $oOApp = ObjCreate("Outlook.Application") Global $test = ObjEvent($oOApp, "oOApp_") While 1     Sleep(400) WEnd FileDelete("D:\attachment\*.*") FileDelete("D:\Email-Details\*.*") FileDelete("D:\Script-temp\*.*") FileDelete("D:\Downloaded-Cert\*.*") FileDelete("D:\LOG\*.*") RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE) ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sOL_EntryId)     FileDelete("D:\attachment\*.*")     FileDelete("D:\Email-Details\*.*")     FileDelete("D:\Script-temp\*.*")     FileDelete("D:\Downloaded-Cert\*.*")     FileDelete("D:\LOG\*.*")     RunWait("taskkill /F /IM iexplore.exe /T", "", @SW_HIDE)     Sleep(1000)     Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)     Sleep(1000)     _OL_ItemAttachmentSave($oOApp, $oOL_Item, Default, 1, "D:\attachment\")     Sleep(1000)     ;MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _     ;"From:    " & $oOL_Item.SenderName & @CRLF & _     ;"Subject: " & $oOL_Item.Subject)     Local $oOL_Item1 = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)     Sleep(1000)     Local $oOL_Sender = $oOL_Item1.Sender     If $oOL_Sender.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Sender.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then         Local $oExchangeUser = $oOL_Sender.GetExchangeUser     Else         Sleep(2000)     EndIf     Sleep(1000)     Local $sendername = ("D:\Email-Details\sendername.txt")     Local $Subject = ("D:\Email-Details\subject.txt")     ;=================================Subjectfile file write ===========================================     Local $Subject1 = FileOpen($Subject, $FO_APPEND)     If $Subject1 = -1 Then         MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the Subject file.")         Return False     EndIf     ; Write data to the file using the handle returned by FileOpen.     FileWrite($Subject1, $oOL_Item1.Subject)     ; Close the handle returned by FileOpen.     FileClose($Subject1)     Sleep(1000) ;=================================End sendername file write ===========================================     $Filerunpath = ("C:\Users\certauto\Desktop\Test.Exe")     Local $iPID = Run($Filerunpath)     ProcessWaitClose($iPID)     Sleep(1000)     _OL_ItemModify($oOApp, $oOL_Item, Default, "Unread=False")     ;$openemail = WinActivate ( "[CLASS:NetUIHWND; INSTANCE:1]", "" )     ;ControlClick($openemail, "", "NUIDialog")     ;$oOApp.Session.Logoff     Sleep(1000)     ;====================Mark email as read===========================================     ;_OL_ItemModify($oOL_Item,$oOApp.Session.GetItemFromID($sOL_EntryId, Default, "Unread=False")     Sleep(1000) EndFunc   ;==>oOApp_NewMailEx Func _Exit()     Exit EndFunc   ;==>_Exit
    • By Skysnake
      This assumes implementation of the OutlookEX UDF.
      I have PSTs which are becoming unmanageable 
      The idea is to make a simple GUI (Listview) which can combine non-Outlook data and include emails based on criteria.  Manage them in the GUI (delete / reply etc) and update to Outlook.
      So the issue would be to manage the items in the GUI while using the PST as a database.
      Ideas on how to do this? What would the key be?
    • By Reizvoller
      Howdy!
      I've been reading through the OutLookEX documentation and examples for the past two days ( VERY well documented, very clear! ) 
      https://www.autoitscript.com/wiki/OutlookEX_UDF_-_General
       
      But I've had trouble locating information on specifying what user to use. My outlook is linked to two email accounts and I can only manipulate the main account's stuff. A simple script I've been playing with is this 
      ; Include Functions #include <OutlookEX.au3> ; Connect to Outlook Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "Connect to Outlook", "Error connecting to Outlook. @error = " & @error & ", @extended = " & @extended) ;List the folders Global $aResult = _OL_FolderTree($oOutlook, "*") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_FolderTree Example Script", "Error accessing root folder. @error = " & @error) _ArrayDisplay($aResult, "OutlookEX UDF: _OL_FolderTree Example Script - All folders") It works like a charm but it only returns my main account's folders. 
      I really hope I didn't overlook a wiki page or help file... 
      Any assistance would be greatly appreciated!
      -Reiz
    • By galan2015
      Is there any solution on receiving e-mails? I would like to create a script so that I will not have to log in through the browser.
×
×
  • Create New...