Jump to content

water

MVPs
  • Posts

    26,783
  • Joined

  • Last visited

  • Days Won

    206

water last won the day on November 19 2025

water had the most liked content!

About water

Recent Profile Visitors

15,349 profile views

water's Achievements

  1. Func _OL_ItemTaskComplete($olItem) $olItem.FlagStatus = 1 ; 1 = olFlagComplete $olItem.Save Return EndFunc ;==>_OL_ItemTaskComplete This function sets the green check mark. Property FlagStatus (and others) are deprecated. But MS does not explain (at least I haven't found any good documentations) how to replace this properties. This means: Don't rely too much on the deprecated properties.
  2. My (incomplete) understanding is: We need a function to create a task from an item (_OL_ItemTaskMark). This method sets the value of several other properties, depending on the value provided in MarkInterval. When a mail has been marked as task you can change this new properties using _OL_ItemModify. To unmark a task another function is needed (_OL_ItemTaskUnmark). I guess that all properties created by _OL_ItemTaskMark are deleted then (NEED TO CHECK). I noticed that I missed to call the Save Method in _OL_ItemTaskMark. This might be the cause of your problem. The task existed until Outlook was closed (NEED TO CHECK). Here are the latest versions of this two functions: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_ItemTaskMark ; Description ...: Marks an item as a task and assigns a task interval for the item. ; Syntax.........: _OL_ItemTaskMark($oOL, $vItem, $sStoreID, $iInterval) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vItem - EntryID or object of the item ; $sStoreID - StoreID where the EntryID is stored. Use the keyword "Default" to use the users mailbox ; $iInterval - Time period for which the item is marked as a task. Defined by the $OlMarkInterval Enumeration ; Return values .: Success - Item object ; Failure - Returns 0 and sets @error: ; |1 - No Outlook item specified ; |2 - Item could not be found. EntryID might be wrong. @extended is set to the COM error ; |3 - $iInterval is not a number ; |4 - Method MarkAsTask returned an error. @extended is set to the COM error ; Author ........: water ; Modified ......: ; Remarks .......: This function sets the value of several other properties, depending on the value provided in $iInterval. ; For more information about the properties set see the link below (OlMarkInterval Enumeration). ; This function supports ContactItem, DistListItem, MailItem, PostItem and SharingItem objects. ; To change this or set further properties please call _OL_ItemModify. ; Related .......: _OL_ItemTaskUnmark ; Link ..........: OlMarkInterval Enumeration: http://msdn.microsoft.com/en-us/library/bb208108(v=office.12).aspx ; Example .......: Yes ; =============================================================================================================================== Func _OL_ItemTaskMark($oOL, $vItem, $sStoreID, $iInterval) 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(2, @error, 0) EndIf If Not IsInt($iInterval) Then SetError(3, 0, 0) $vItem.MarkAsTask($iInterval) If @error Then Return SetError(4, @error, 0) $vItem.Save() Return $vItem EndFunc ;==>_OL_ItemTaskMark ; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_ItemTaskUnmark ; Description ...: Unmarks an item already marked as a task. ; Syntax.........: _OL_ItemTaskUnmark($oOL, $vItem, $sStoreID) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vItem - EntryID or object of the item ; $sStoreID - StoreID where the EntryID is stored. Use the keyword "Default" to use the users mailbox ; Return values .: Success - Item object ; Failure - Returns 0 and sets @error: ; |1 - No Outlook item specified ; |2 - Item could not be found. EntryID might be wrong. @extended is set to the COM error ; |3 - Method ClearTaskFlag returned an error. @extended is set to the COM error ; Author ........: water ; Modified ......: ; Remarks .......: Calling this method sets the IsMarkedAsTask property to False. ; Related .......: _OL_ItemTaskMark ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_ItemTaskUnmark($oOL, $vItem, $sStoreID) 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(2, @error, 0) EndIf $vItem.ClearTaskFlag() If @error Then Return SetError(3, @error, 0) $vItem.Save() Return $vItem EndFunc ;==>_OL_ItemTaskUnmark I'll be back as soon as I have finished the tests
  3. The task has been completed, but the mail is still marked as a task - and that is, what you test for in the second run. You need to unmark the mail item. The next release of the UDF will have the following additional function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _OL_ItemTaskUnmark ; Description ...: Unmarks an item already marked as a task. ; Syntax.........: _OL_ItemTaskUnmark($oOL, $vItem, $sStoreID) ; Parameters ....: $oOL - Outlook object returned by a preceding call to _OL_Open() ; $vItem - EntryID or object of the item ; $sStoreID - StoreID where the EntryID is stored. Use the keyword "Default" to use the users mailbox ; Return values .: Success - Item object ; Failure - Returns 0 and sets @error: ; |1 - No Outlook item specified ; |2 - Item could not be found. EntryID might be wrong. @extended is set to the COM error ; |3 - Method ClearTaskFlag returned an error. @extended is set to the COM error ; Author ........: water ; Modified ......: ; Remarks .......: Calling this method sets the IsMarkedAsTask property to False. ; Related .......: _OL_ItemTaskMark ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _OL_ItemTaskUnmark($oOL, $vItem, $sStoreID) 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(2, @error, 0) EndIf $vItem.ClearTaskFlag() If @error Then Return SetError(3, @error, 0) $vItem.Save() Return $vItem EndFunc ;==>_OL_ItemTaskUnmark Call this function after _OL_ItemModify.
  4. You are correct, False does not work, "False" does. It was an copy/paste error on my side 😏 I fixed my wrong post above. So all your questions could be answered?
  5. Should be: $aItems = _OL_ItemFind($oOutlook, $aMailFolder[1], $olMail, "", "IsMarkedAsTask", "False", "Subject,@ItemObject,IsMarkedAsTask,TaskDueDate", "", 8)
  6. Here is the correct Link
  7. I couldn't get DASL to work, but _OL_ItemFind works great here: #include <OutlookEx.au3> Global $oOutlook, $aMailFolder ; Set the error handler _OL_ErrorNotify(2) $oOutlook = _OL_Open() ; Get the Inbox object $aMailFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox) ; Find all items with IsMarkedAsTask=True ; Return some properties plus the items object $aItems = _OL_ItemFind($oOutlook, $aMailFolder[1], $olMail, "", "IsMarkedAsTask", True, "Subject,@ItemObject,IsMarkedAsTask,TaskDueDate", "", 8) If @error = 0 Then _ArrayDisplay($aItems) Else MsgBox($MB_ICONERROR, "OutlookEX UDF", "_OL_ItemFind returned an error. @error = " & @error & ", @extended: " & @extended) EndIf If this works for you as well I should be able to answer the remaining questions: DONE: How could we filter these emails (not marked as completed) with an alternative to FlagStatus? Solution: Use _OL_ItemFind. DONE: What would be the best option for marking emails as completed? Solution: Use _OL_ItemModify and set property TaskCompletedDate. DONE: Can MarkAsTask be changed for email items with _OL_ItemModify function? Solution: No. A new function is required like: Func _OL_ItemTaskUnmark($vItem) $vItem.ClearTaskFlag() $vItem.Save() EndFunc ;==>_OL_ItemTaskUnmark If this works for you I will add the new functions to the UDF and enhance the wiki documentation BTW: This site offers some great insight.
  8. It seems to be invalid to create a "follow-up task" and set it to "completed" in one go.
  9. Dear Robertocm, I had a quick look at the OutlookEx UDF and noticed, that there is only a single function available to work with "follow-up tasks": _OL_Item2Task Seems that not many users had the need for this or further functions. So I need to do some investigation and create functions to query and modify "follow-up tasks". I think I found some good VBA code to query such tasks and hope to come up with a AutoIt function quite soon. Please stay tuned
  10. Thanks for your contribution but I'm not sure what do with your test results: Is this post for a user who had a question regarding the FlagStatus property? Should I add the listed constants to the UDF? Something else?
  11. Strange 🤔 As we have a working solution for strings you could loop through the array and move cell by cell. This will slow down your script, so it depends on the size of your array if this is a solution for you. If our solution for strings does not work when passing an array cell, then please copy the array cell to variable and then call our solution.
  12. Quick and Dirty: Your data gets written to a temporary Range and then copied to the range specified by you. If this works thenthis code needs to be made more flexible and cleanup the temp. data etc. #include <Excel.au3> Global $aArray[1][4] $aArray[0][0] = "1" For $i = 1 to 8203 $aArray[0][1] &= "A" Next For $i = 1 to 8204 $aArray[0][2] &= "B" Next $aArray[0][3] = 2 ConsoleWrite("String length of Array[0][1]: " & StringLen($aArray[0][1]) & @CRLF) ConsoleWrite("String length of Array[0][2]: " & StringLen($aArray[0][2]) & @CRLF) Local $oError = ObjEvent("AutoIt.Error", "_ErrorHandler") $Excel = _Excel_Open() $ExcelBook = _Excel_BookNew($Excel) _Excel_RangeWriteEX($ExcelBook, Default, $aArray, "A1", True, True) If @Error then MsgBox(0, "Error", "Error _Excel_RangeWriteEX: " & @error & @CRLF & "Extended: " & @extended) ; #FUNCTION# ==================================================================================================================== ; Author ........: SEO <locodarwin at yahoo dot com> ; Modified.......: litlmike, PsaltyDS, Golfinhu, water ; =============================================================================================================================== Func _Excel_RangeWriteEX($oWorkbook, $vWorksheet, $vValue, $vRange = Default, $bValue = Default, $bForceFunc = Default) ; Error handler, automatic cleanup at end of function ; Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc") #forceref $oError If Not IsObj($oWorkbook) Or ObjName($oWorkbook, 1) <> "_Workbook" Then Return SetError(1, 0, 0) If Not IsObj($vWorksheet) Then If $vWorksheet = Default Then $vWorksheet = $oWorkbook.ActiveSheet Else $vWorksheet = $oWorkbook.WorkSheets.Item($vWorksheet) EndIf If @error Or Not IsObj($vWorksheet) Then Return SetError(2, @error, 0) ElseIf ObjName($vWorksheet, 1) <> "_Worksheet" Then Return SetError(2, @error, 0) EndIf If $vRange = Default Then $vRange = "A1" If $bValue = Default Then $bValue = True If $bForceFunc = Default Then $bForceFunc = False If Not IsObj($vRange) Then $vRange = $vWorksheet.Range($vRange) If @error Or Not IsObj($vRange) Then Return SetError(3, @error, 0) EndIf If Not IsArray($vValue) Then If $bValue Then $vRange.Value = $vValue Else $vRange.Formula = $vValue EndIf If @error Then Return SetError(4, @error, 0) Else If $vRange.Columns.Count = 1 And $vRange.Rows.Count = 1 Then If UBound($vValue, 0) = 1 Then $vRange = $vRange.Resize(UBound($vValue, 1), 1) Else $vRange = $vRange.Resize(UBound($vValue, 1), UBound($vValue, 2)) EndIf EndIf If $bForceFunc Then _ArrayTranspose($vValue) If $bValue Then Local $vRange2 = $vWorksheet.Range("A3:D3") ; Added $vRange2.Value = $vValue ; Added $vWorksheet.Range("A1:D1") = $vRange2.Value ; Added ; $vRange.Value = $vValue ; Dropped Else $vRange.Formula = $vValue EndIf If @error Then Return SetError(5, @error, 0) Else Local $oExcel = $oWorkbook.Parent If $bValue Then $vRange.Value = $oExcel.Transpose($vValue) Else $vRange.Formula = $oExcel.Transpose($vValue) EndIf If @error Then Return SetError(6, @error, 0) EndIf EndIf Return $vRange EndFunc ;==>_Excel_RangeWriteEX ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _ErrorHandler ; Description ...: Called if an ObjEvent error occurs. ; Syntax.........: __Outlook_ErrorHandler() ; Parameters ....: None ; Return values .: @error is set to the COM error by AutoIt ; Author ........: water ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _ErrorHandler() Local $sError = "COM Error Encountered in " & @ScriptName & @CRLF & _ "@AutoItVersion = " & @AutoItVersion & @CRLF & _ "@AutoItX64 = " & @AutoItX64 & @CRLF & _ "@Compiled = " & @Compiled & @CRLF & _ "@OSArch = " & @OSArch & @CRLF & _ "@OSVersion = " & @OSVersion & @CRLF & _ "Scriptline = " & $oError.Scriptline & @CRLF & _ "NumberHex = 0x" & Hex($oError.Number, 8) & @CRLF & _ "Number = " & $oError.Number & @CRLF & _ "WinDescription = " & StringStripWS($oError.WinDescription, $STR_STRIPTRAILING) & @CRLF & _ "Description = " & StringStripWS($oError.Description, $STR_STRIPTRAILING) & @CRLF & _ "Source = " & $oError.Source & @CRLF & _ "HelpFile = " & $oError.HelpFile & @CRLF & _ "HelpContext = " & $oError.HelpContext & @CRLF & _ "LastDllError = " & $oError.LastDllError ConsoleWrite($sError & @CRLF) EndFunc ;==>_ErrorHandler
  13. Great!! The difference between working and not working is the use of ".Value" in the assignment statement. Seems Excel is a bit overly precise here - but doesn't tell us Could you please run the following script? It's an extended version of your first script with added COM error handling. So we know if there are more problems we need to handle. The error messages get written to the Console. #include <Excel.au3> Global $aArray[1][4] $aArray[0][0] = "1" For $i = 1 to 8203 $aArray[0][1] &= "A" Next For $i = 1 to 8204 $aArray[0][2] &= "B" Next $aArray[0][3] = 2 ConsoleWrite("String length of Array[0][1]: " & StringLen($aArray[0][1]) & @CRLF) ConsoleWrite("String length of Array[0][2]: " & StringLen($aArray[0][2]) & @CRLF) Local $oError = ObjEvent("AutoIt.Error", "_ErrorHandler") $Excel = _Excel_Open() $ExcelBook = _Excel_BookNew($Excel) _Excel_RangeWriteEX($ExcelBook, Default, $aArray, "A1", True, True) If @Error then MsgBox(0, "Error", "Error _Excel_RangeWriteEX: " & @error & @CRLF & "Extended: " & @extended) ; #FUNCTION# ==================================================================================================================== ; Author ........: SEO <locodarwin at yahoo dot com> ; Modified.......: litlmike, PsaltyDS, Golfinhu, water ; =============================================================================================================================== Func _Excel_RangeWriteEX($oWorkbook, $vWorksheet, $vValue, $vRange = Default, $bValue = Default, $bForceFunc = Default) ; Error handler, automatic cleanup at end of function ; Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc") #forceref $oError If Not IsObj($oWorkbook) Or ObjName($oWorkbook, 1) <> "_Workbook" Then Return SetError(1, 0, 0) If Not IsObj($vWorksheet) Then If $vWorksheet = Default Then $vWorksheet = $oWorkbook.ActiveSheet Else $vWorksheet = $oWorkbook.WorkSheets.Item($vWorksheet) EndIf If @error Or Not IsObj($vWorksheet) Then Return SetError(2, @error, 0) ElseIf ObjName($vWorksheet, 1) <> "_Worksheet" Then Return SetError(2, @error, 0) EndIf If $vRange = Default Then $vRange = "A1" If $bValue = Default Then $bValue = True If $bForceFunc = Default Then $bForceFunc = False If Not IsObj($vRange) Then $vRange = $vWorksheet.Range($vRange) If @error Or Not IsObj($vRange) Then Return SetError(3, @error, 0) EndIf If Not IsArray($vValue) Then If $bValue Then $vRange.Value = $vValue Else $vRange.Formula = $vValue EndIf If @error Then Return SetError(4, @error, 0) Else If $vRange.Columns.Count = 1 And $vRange.Rows.Count = 1 Then If UBound($vValue, 0) = 1 Then $vRange = $vRange.Resize(UBound($vValue, 1), 1) Else $vRange = $vRange.Resize(UBound($vValue, 1), UBound($vValue, 2)) EndIf EndIf If $bForceFunc Then _ArrayTranspose($vValue) If $bValue Then $vRange.Value = $vValue Else $vRange.Formula = $vValue EndIf If @error Then Return SetError(5, @error, 0) Else Local $oExcel = $oWorkbook.Parent If $bValue Then $vRange.Value = $oExcel.Transpose($vValue) Else $vRange.Formula = $oExcel.Transpose($vValue) EndIf If @error Then Return SetError(6, @error, 0) EndIf EndIf Return $vRange EndFunc ;==>_Excel_RangeWriteEX ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name ..........: _ErrorHandler ; Description ...: Called if an ObjEvent error occurs. ; Syntax.........: __Outlook_ErrorHandler() ; Parameters ....: None ; Return values .: @error is set to the COM error by AutoIt ; Author ........: water ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _ErrorHandler() Local $sError = "COM Error Encountered in " & @ScriptName & @CRLF & _ "@AutoItVersion = " & @AutoItVersion & @CRLF & _ "@AutoItX64 = " & @AutoItX64 & @CRLF & _ "@Compiled = " & @Compiled & @CRLF & _ "@OSArch = " & @OSArch & @CRLF & _ "@OSVersion = " & @OSVersion & @CRLF & _ "Scriptline = " & $oError.Scriptline & @CRLF & _ "NumberHex = 0x" & Hex($oError.Number, 8) & @CRLF & _ "Number = " & $oError.Number & @CRLF & _ "WinDescription = " & StringStripWS($oError.WinDescription, $STR_STRIPTRAILING) & @CRLF & _ "Description = " & StringStripWS($oError.Description, $STR_STRIPTRAILING) & @CRLF & _ "Source = " & $oError.Source & @CRLF & _ "HelpFile = " & $oError.HelpFile & @CRLF & _ "HelpContext = " & $oError.HelpContext & @CRLF & _ "LastDllError = " & $oError.LastDllError ConsoleWrite($sError & @CRLF) EndFunc ;==>_ErrorHandler
  14. Step 1: Done Step 2: Done Could you please create 2 AutoIt scripts from the following code and test Error8204.au3 (and hopefully get an error msgbox as I did), then run Working8204.au3 and - keep your fingers crossed - get no error. Please post your results ; Error8204.au3 #include <Excel.au3> Local $sX, $oExcel, $oWorkBook, $oActiveWorksheet For $i = 1 To 8204 $sX &= "B" Next ConsoleWrite("String length of $sX: " & StringLen($sX) & @CRLF) $oExcel = _Excel_Open() If @error Then MsgBox(0, "Error", "_Excel_Open Error: " & @error & @CRLF & "Extended: " & @extended) $oWorkBook = _Excel_BookNew($oExcel) If @error Then MsgBox(0, "Error", "_Excel_BookNew Error: " & @error & @CRLF & "Extended: " & @extended) ; _Excel_RangeWrite($ExcelBook, Default, $Array, "A1") ; , True, True) $oActiveWorksheet = $oWorkBook.ActiveSheet If @error Then MsgBox(0, "Error", "Get active Sheet Error: " & @error & @CRLF & "Extended: " & @extended) $oActiveWorksheet.Range("A1").Value = $sX If @error Then MsgBox(0, "Error", "_Assign to Range A1 Error: " & @error & @CRLF & "Extended: " & @extended) $oActiveWorksheet.Range("A2") = $oActiveWorksheet.Range("A1") If @error Then MsgBox(0, "Error", "_Assign to Range A2 Error: " & @error & @CRLF & "Extended: " & @extended) ; Working8204.au3 #include <Excel.au3> Local $sX, $oExcel, $oWorkBook, $oActiveWorksheet For $i = 1 To 8204 $sX &= "B" Next ConsoleWrite("String length of $sX: " & StringLen($sX) & @CRLF) $oExcel = _Excel_Open() If @error Then MsgBox(0, "Error", "_Excel_Open Error: " & @error & @CRLF & "Extended: " & @extended) $oWorkBook = _Excel_BookNew($oExcel) If @error Then MsgBox(0, "Error", "_Excel_BookNew Error: " & @error & @CRLF & "Extended: " & @extended) $oActiveWorksheet = $oWorkBook.ActiveSheet If @error Then MsgBox(0, "Error", "Get active Sheet Error: " & @error & @CRLF & "Extended: " & @extended) $oActiveWorksheet.Range("A1").Value = $sX If @error Then MsgBox(0, "Error", "_Assign to Range A1 Error: " & @error & @CRLF & "Extended: " & @extended) $oActiveWorksheet.Range("A2") = $oActiveWorksheet.Range("A1").Value If @error Then MsgBox(0, "Error", "_Assign to Range A2 Error: " & @error & @CRLF & "Extended: " & @extended)
  15. This site describes the problem you see and offers a working solution as well. Seems you need to create a user function (like _Excel_RangeWriteSpecial), copy _Excel_RangeWrite to your function and insert the lines described after "I was able to solve the error by adding .value to the copy." First we need an AutoIt script to reproduce the problem with a string as described on the mentioned site Next step is to translate the solution to AutoIt Last step is to modify the solution for an array I'm working on step 1 at the moment
×
×
  • Create New...