water Posted October 20, 2020 Author Share Posted October 20, 2020 If you run the _OL_Wrapper_SendMail.au3 example script do you get an error message or a success message? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
seadoggie01 Posted October 21, 2020 Share Posted October 21, 2020 Works on Office 365 ProPlus (2016? 😕) - Version 2002 (we're on the Semi-Annual Enterprise Channel at work). I'll try to remember to check when I get home, I probably have a later version. 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
seadoggie01 Posted October 22, 2020 Share Posted October 22, 2020 (edited) Tested with Outlook 365 Version 2009. _OL_ItemSend returns Error 2, Extended 0x80070057 This appears to be an Outlook issue. You can solve it by not using the ".GetInspector" property of an item or by using it and then activating the inspector (See this MSDN thread) If you experience this issue, replacing _OL_Wrapper_SendMail with _OL_Wrapper_SendMail_Temp and adding this function (might) resolve your issue: Spoiler expandcollapse popupFunc _OL_Wrapper_SendMail_Temp($oOL, $sTo = "", $sCc = "", $sBCc = "", $sSubject = "", $sBody = "", $sAttachments = "", $iBodyFormat = $olFormatPlain, $iImportance = $olImportanceNormal) If $sTo = Default Then $sTo = "" If $sCc = Default Then $sCc = "" If $sBCc = Default Then $sBCc = "" If $sSubject = Default Then $sSubject = "" If $sBody = Default Then $sBody = "" If $sAttachments = Default Then $sAttachments = "" If $iBodyFormat = Default Then $iBodyFormat = $olFormatPlain If $iImportance = Default Then $iImportance = $olImportanceNormal If Not IsInt($iBodyFormat) Then SetError(1, 0, 0) If StringStripWS($sBody, 3) = "" Then SetError(2, 0, 0) If StringStripWS($sTo, 3) = "" And StringStripWS($sCc, 3) = "" And StringStripWS($sBCc, 3) = "" Then SetError(3, 0, 0) ; Access the default outbox folder Local $aFolder = _OL_FolderAccess($oOL, "", $olFolderDrafts) If @error Then Return SetError(@error + 1000, @extended, 0) ; Create a mail item in the default folder Local $oItem = _OL_ItemCreate($oOL, $olMailItem, $aFolder[1], "", "Subject=" & $sSubject, "BodyFormat=" & $iBodyFormat, "Importance=" & $iImportance) If @error Then Return SetError(@error + 2000, @extended, 0) ; Set the body according to $iBodyFormat If $iBodyFormat = $olFormatHTML Then _OL_ItemModify($oOL, $oItem, Default, "HTMLBody=" & $sBody) Else _OL_ItemModify($oOL, $oItem, Default, "Body=" & $sBody) EndIf If @error Then Return SetError(@error + 3000, @extended, 0) ; Add recipients (to, cc and bcc) Local $aRecipients If $sTo <> "" Then $aRecipients = StringSplit($sTo, ";", 2) _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $aRecipients) If @error Then Return SetError(@error + 4000, @extended, 0) EndIf If $sCc <> "" Then $aRecipients = StringSplit($sCc, ";", 2) _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCC, $aRecipients) If @error Then Return SetError(@error + 4000, @extended, 0) EndIf If $sBCc <> "" Then $aRecipients = StringSplit($sBCc, ";", 2) _OL_ItemRecipientAdd($oOL, $oItem, Default, $olBCC, $aRecipients) If @error Then Return SetError(@error + 4000, @extended, 0) EndIf ; Add attachments If $sAttachments <> "" Then Local $aAttachments = StringSplit($sAttachments, ";", 2) _OL_ItemAttachmentAdd($oOL, $oItem, Default, $aAttachments) If @error Then Return SetError(@error + 5000, @extended, 0) EndIf ; ================================================================================================== ; Should be removed later, makes messages flash before sending, but allows them to be sent for now ; Creates a window to edit the email in and activates it to avoid COM Error 80070057 on Item.Send $oItem.GetInspector.Activate If @error Then Return SetError(7001, @extended, 0) ; ================================================================================================== ; Send mail _OL_ItemSend($oOL, $oItem, Default) If @error Then Return SetError(@error + 6000, @extended, 0) Return $oItem EndFunc Edit: Please don't use this code, use water's code and instructions below Edited October 27, 2020 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Confuzzled Posted October 23, 2020 Share Posted October 23, 2020 (edited) Good find! Do you need a _OL_VersionInfo() wrapped around your workaround for the bypass for the buggy version, or is this going to be fixed in the next MSOutlook bugfix update by Microsoft? Edited October 23, 2020 by Confuzzled Link to comment Share on other sites More sharing options...
seadoggie01 Posted October 23, 2020 Share Posted October 23, 2020 No, don't edit OutlookEx.au3. Simply add that function to your script(s) and use it temporarily until Outlook is updated. Hopefully Microsoft will fix the issue before long, but I don't know if it's being considered a bug. I would avoiding editing any include files unless you must. You want to avoid causing further issues and/or confusion by introducing new bugs or changes. I'm not actually sure if what I posted is perfect anyways... the double property accessor causes issues in the current version of AutoIt. $vItem.GetInspector.Activate might throw an uncatchable COM error if .GetInspector fails. 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
water Posted October 24, 2020 Author Share Posted October 24, 2020 Would something like this solve your problem? I check @error after .Send. If we get 0x80070057 we can execute all statements to solve the problem. Func _OL_ItemSend($oOL, $vItem, $sStoreID = Default) Local $oInspector Local Const $olMinimized = 1 ; The window is minimized If Not IsObj($vItem) Then If StringStripWS($vItem, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then Return SetError(1, 0, 0) $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID) If @error Then Return SetError(1, @error, 0) EndIf $vItem.Send() If @error Then ; Handle the MAPI_E_INVALID_PARAMETER (HRESULT 0x80070057) error found in Outlook 365 Version 2009. ; Described here and the following posts: https://www.autoitscript.com/forum/topic/126305-outlookex-udf/?do=findComment&comment=1466457 If @error = 0x80070057 Then $oInspector = $vItem.GetInspector $oInspector.Activate $oInspector.WindowState = $olMinimized $vItem.Send() If @error Then Return SetError(2, @error, 0) Else Return SetError(2, @error, 0) EndIf EndIf Return $vItem EndFunc ;==>_OL_ItemSend Skysnake and seadoggie01 2 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
alfev Posted October 26, 2020 Share Posted October 26, 2020 Hi, thanks for looking at this everyone. I'm not sure from above if we have a workaround. I only dable in Autoit occasionally, so a bit confused. I tried using _OL_Wrapper_SendMail_Temp instead of _OL_Wrapper_SendMail but the function wasn't recognised. Link to comment Share on other sites More sharing options...
water Posted October 26, 2020 Author Share Posted October 26, 2020 Seadoggie01 just expained how to create a new function that does not interfere with the OutlookEX UDF. If you want to go this route you need to write the Temp function yourself. Or we extend _OL_Wrapper_SendMail to cope with the error (like the example I posted above). Skysnake 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Skysnake Posted October 27, 2020 Share Posted October 27, 2020 Sent Items, not Draft No coincidence that this is suddenly an issue. I have extensive opportunity to test. @water can I simply copy& replace the function above into the standard UDF (replace the original?) - would that be good enough? Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
alfev Posted October 27, 2020 Share Posted October 27, 2020 @water thanks for your help with this, that sorted it for me. As an idiot, I'm uniquely positioned for writing a short idiots guide to resolving this... Create a backup copy of ... C:\Program Files (x86)\AutoIt3\Include\OutlookEX.au3 Edit the original OutlookEX.au3, find the section that looks like this... Func _OL_ItemSend($oOL, $vItem, $sStoreID = Default) If Not IsObj($vItem) Then If StringStripWS($vItem, 3) = "" Then Return SetError(1, 0, 0) $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID) If @error Then Return SetError(1, @error, 0) EndIf $vItem.Send() If @error Then Return SetError(2, @error, 0) Return $vItem EndFunc ;==>_OL_ItemSend Replace it with the copy @water wrote... Func _OL_ItemSend($oOL, $vItem, $sStoreID = Default) Local $oInspector Local Const $olMinimized = 1 ; The window is minimized If Not IsObj($vItem) Then If StringStripWS($vItem, BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)) = "" Then Return SetError(1, 0, 0) $vItem = $oOL.Session.GetItemFromID($vItem, $sStoreID) If @error Then Return SetError(1, @error, 0) EndIf $vItem.Send() If @error Then ; Handle the MAPI_E_INVALID_PARAMETER (HRESULT 0x80070057) error found in Outlook 365 Version 2009. ; Described here and the following posts: https://www.autoitscript.com/forum/topic/126305-outlookex-udf/?do=findComment&comment=1466457 If @error = 0x80070057 Then $oInspector = $vItem.GetInspector $oInspector.Activate $oInspector.WindowState = $olMinimized $vItem.Send() If @error Then Return SetError(2, @error, 0) Else Return SetError(2, @error, 0) EndIf EndIf Return $vItem EndFunc ;==>_OL_ItemSend Save OutlookEx.au3 Recompile your script. Sorted, thanks. Skysnake 1 Link to comment Share on other sites More sharing options...
Skysnake Posted October 27, 2020 Share Posted October 27, 2020 A thought crossed my mind. Perhaps these functions should exist as alternatives. Turn this functionality into a feature? Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
water Posted October 27, 2020 Author Share Posted October 27, 2020 Before modifying the OutlookEX UDF I would test the new _OL_ItemSend function. As I do not have the required version of Outlook you need to do the testing. I suggest: Copy function _OL_Wrapper_ItemSend from OutlookEX.au3 to your test script that triggers the Outlook bug Rename the copied _OL_Wrapper_ItemSend function to _OL_Wrapper_ItemSendEX In _OL_Wrapper_ItemSendEX change the function call from _OL_ItemSend to _OL_ItemSendEX Add the updated _OL_ItemSend function as _OL_ItemSendEX to your test script Modify your script so you always call _OL_Wrapper_ItemSendEX Optional: Add some debugging statements to _OL_Wrapper_ItemSendEX to make sure the "repair code" gets triggered and runs successfully My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
water Posted October 27, 2020 Author Share Posted October 27, 2020 16 minutes ago, Skysnake said: Perhaps these functions should exist as alternatives. Turn this functionality into a feature? That's my plan As the added code only gets triggered by the described Outlook bug it wouldn't hurt any existing installation but helps users who got hit by the bug. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Confuzzled Posted October 30, 2020 Share Posted October 30, 2020 Question remains: Do you urgently release a new version of OutlookEX UDF that has an internal test for the buggy version of Office and automagically performs the bypass, otherwise silently continues as if nothing was wrong? Who knows how long before Microsoft will issue a patch to fix this? Once you have the added bloat in there to fix a problem, do you retain it for ever for backward compatibility, assuming somebody (like the NHS with their covid #spreadshit fiasco) will never update their Office suite? You cannot expect developers to keep tabs on what versions of software are out there and customise their deployed versions. Add the bloat workaround and interoperate I say. Link to comment Share on other sites More sharing options...
water Posted October 30, 2020 Author Share Posted October 30, 2020 42 minutes ago, Confuzzled said: Do you urgently release a new version of OutlookEX UDF that has an internal test for the buggy version of Office and automagically performs the bypass, otherwise silently continues as if nothing was wrong? That's my plan. But I do not check for the buggy version. I check for the COM error code (0x80070057). Has someone tested the _OL_ItemSend function with the workaround I posted above? If it solves your problem I could release a new version in a few hours. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Confuzzled Posted October 30, 2020 Share Posted October 30, 2020 Does that error code get triggered for any other scenario than the buggy version of Office? Is the workaround that has been offered here the only one for that situation? I recommend you check both the version and the faulty error code to make it more robust and deploy the update after you have confirmed it bypasses the problem. Link to comment Share on other sites More sharing options...
water Posted October 30, 2020 Author Share Posted October 30, 2020 The COM error code 0x80070057 stands for: The parameter is incorrect (E_INVALIDARG). The used Send method does not accept any parameters - so the COM error can only be raised by the Outlook bug. 1 hour ago, Confuzzled said: Is the workaround that has been offered here the only one for that situation? I can't test - I do not have the buggy Outlook version installed. So members of this forum with access to the buggy version of Outlook need to test the posted workaround. If I get their OK I will implement the workaround and release a new version of the UDF. seadoggie01 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
seadoggie01 Posted November 1, 2020 Share Posted November 1, 2020 @water, I tested this and it works for me perfectly! Skysnake 1 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
water Posted December 11, 2020 Author Share Posted December 11, 2020 Version 1.6.3.0 of the UDF has been released! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
corbeau56 Posted December 15, 2020 Share Posted December 15, 2020 (edited) I wrote a script to save emails in a company's specific folder. It works very fine on Outlook 365 but has got a strange behaviour. The script is saving the email as wanted, but at the end of the script, the _OL_Close($oOutlook) command is closing the Outlook application. This only happens for about 1 or 2 minutes after starting Outlook. When the Outlook application window is open for a certain time, the script ends without closing the Outlook application. My collegue is using the script on his computer without this behaviour. Any ideas? Greetings from Germany Matthias Edit: In both cases (script working properly or script closing the Outlook application), the _OL_Close function is returning value 1 for success. Edit2: It seems, that shortly after opening the Outlook application, the starting of my script is returning a zero value in the @extended variable of the _OL_Open function. About 1 or 2 minutes after starting Outlook, the same script is returning the value 1 in @extended. Edited December 15, 2020 by corbeau56 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