Jump to content

Trying to export all mail in my Outlook Inbox into MSG files. Some work, some dont.


Tjalve
 Share

Recommended Posts

  • Replies 86
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

here we go.

_OL_ItemFind: 0 items found <--- Works

Ansluter till Inbox... OK

Letar efter nya mail... OK

_OL_ItemFind: 0 items found <--- Works

Ansluter till Inbox... OK

Letar efter nya mail... EntryID: 000000006C0C6CAECE08254FA08F30D22262A0080700A13BA048F004A44DAA6E16469EABD37000000082BEB70000A13BA048F004A44DAA6E16469EABD37000000084D9C90000, Dim1: 2, Dim2: 2, $iCounter: 1, $iIndex: 1

EntryID: 000000006C0C6CAECE08254FA08F30D22262A0080700A13BA048F004A44DAA6E16469EABD37000000082BEB70000A13BA048F004A44DAA6E16469EABD37000000084D9C80000, Dim1:

>Exit code: 1 Time: 3646.534

Link to comment
Share on other sites

EntryID: 000000006C0C6CAECE08254FA08F30D22262A0080700A13BA048F004A44DAA6E16469EABD37000000082BEB70000A13BA048F004A44DAA6E16469EABD37000000084DA7E0000, Dim1: 2, Dim2: 2, $iCounter: 2, $iIndex: 1

C:\Program Files (x86)\AutoIt3\Include\OutlookEx.au3 (2674) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value

^ ERROR

>Exit code: 1 Time: 5498.603

Edited by Tjalve
Link to comment
Share on other sites

here we go.

_OL_ItemFind: 0 items found <--- Works

Ansluter till Inbox... OK

Letar efter nya mail... OK

_OL_ItemFind: 0 items found <--- Works

Ansluter till Inbox... OK

Letar efter nya mail... EntryID: 000000006C0C6CAECE08254FA08F30D22262A0080700A13BA048F004A44DAA6E16469EABD37000000082BEB70000A13BA048F004A44DAA6E16469EABD37000000084D9C90000, Dim1: 2, Dim2: 2, $iCounter: 1, $iIndex: 1

EntryID: 000000006C0C6CAECE08254FA08F30D22262A0080700A13BA048F004A44DAA6E16469EABD37000000082BEB70000A13BA048F004A44DAA6E16469EABD37000000084D9C80000, Dim1:

>Exit code: 1 Time: 3646.534

Can you run the following code and add the EntryID of the mail item (replace "xx") where the script crashed so we can see if the mails is somehow different:

#include <OutlookEx.au3>
$oOutlook = _OL_Open()
_OL_ItemDisplay($oOutlook, "xx")
_OL_Close($oOutlook)
Edited by water

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

I ran the code and opened the last entry ID that was displayed in the console right befor the crash. Its just an ordenary mail with tesxt. Nothing out of the ordenary.

Also if i rerun the script again, it works for that mailitem.

Link to comment
Share on other sites

Did new mails arrive while the script is running?

The array is created with the number of items found, the the items are processed. If new mail arrives during processing this might exceed the size of the array.

Haven't tested it but if new mails arrive during processing I will give it a try.

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

Maybe.

I will have to test ...

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

Verified.

That's exactly the problem. Every item (mail, contact ...) that is created during processing might crash the script.

Function _OL_ItemFind needs a "brush up".

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

Ahh great stuff. Any hope for a solution? Perhaps there is a way to check the number of mails in the inbox agaisn the size of the array. Or as a workaround i can pehaps set outlook in offline mode during the check and then reneble it. But that is just a dirty solution and i would mutch rather have this working ;)

Link to comment
Share on other sites

The PowerShell I use to create the mailbox is described

Make sure to install the necessary Exchange tools and to run the script as 64 bit (PowerShell requirement).

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

Could you please give this enhanced _OL_ItemFind function a try?

Func _OL_ItemFind($oOL, $vFolder, $iObjectClass = Default, $sRestrict = "", $sSearchName = "", $sSearchValue = "", $sReturnProperties = "", $sSort = "", $iFlags = 0, $sWarningClick = "")

Local $bChecked = False, $oItems, $aTemp, $iRecCounter = 0, $iCounter = 0, $oItem
If $sWarningClick <> "" Then
If FileExists($sWarningClick) = 0 Then Return SetError(2, 0, "")
Run($sWarningClick)
EndIf
If $iObjectClass = Default Then $iObjectClass = $olContact ; Set Default ObjectClass
; Set default return properties depending on the class of items
If StringStripWS($sReturnProperties, 3) = "" Then
Switch $iObjectClass
Case $olContact
$sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber"
Case $olDistributionList
$sReturnProperties = "Subject,Body,MemberCount"
Case $olNote, $olMail
$sReturnProperties = "Subject,Body,CreationTime,LastModificationTime,Size"
Case Else
EndSwitch
EndIf
If Not IsObj($vFolder) Then
$aTemp = _OL_FolderAccess($oOL, $vFolder)
If @error Then Return SetError(3, @error, "")
$vFolder = $aTemp[1]
EndIf
If ($sSearchName <> "" And $sSearchValue = "") Or ($sSearchName = "" And $sSearchValue <> "") Then Return SetError(1, 0, "")
Local $aReturnProperties = StringSplit(StringStripWS($sReturnProperties, 8), ",")
Local $iIndex = $aReturnProperties[0]
If $aReturnProperties[0] < 2 Then $iIndex = 2
Local $aItems[$vFolder.Items.Count + 1][$iIndex] = [[0, $aReturnProperties[0]]]
If StringStripWS($sRestrict, 3) = "" Then
$oItems = $vFolder.Items
Else
$oItems = $vFolder.Items.Restrict($sRestrict)
EndIf
If BitAND($iFlags, 4) <> 4 And $sSort <> "" Then
$aTemp = StringSplit($sSort, ",")
If $aTemp[0] = 1 Then
$oItems.Sort($sSort)
Else
$oItems.Sort($aTemp[1], True)
EndIf
EndIf
For $i = 1 To $oItems.Count
$oItem = $oItems.Item($i)
If $oItem.Class <> $iObjectClass Then ContinueLoop
; Get all properties of first item and check for existance and correct case
If BitAND($iFlags, 4) <> 4 And Not $bChecked Then
If Not __OL_CheckProperties($oItem, $aReturnProperties, 1) Then Return SetError(@error, @extended, "")
$bChecked = True
EndIf
If $sSearchName <> "" And StringInStr($oItem.ItemProperties.Item($sSearchName).value, $sSearchValue) = 0 Then ContinueLoop
; Fill array with the specified properties
$iCounter += 1
If BitAND($iFlags, 4) <> 4 Then
For $iIndex = 1 To $aReturnProperties[0]
$aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value
If @error Then Return SetError(4, @error, "")
If BitAND($iFlags, 2) = 2 And $iCounter = 1 Then $aItems[0][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).name
Next
EndIf
If BitAND($iFlags, 4) <> 4 And BitAND($iFlags, 2) <> 2 Then $aItems[0][0] = $iCounter
Next
If BitAND($iFlags, 4) = 4 Then
$iRecCounter += $oItems.Count
; Process subfolders
If BitAND($iFlags, 1) = 1 Then
For $vFolder In $vFolder.Folders
$iRecCounter += _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
Next
EndIf
Return $iRecCounter
Else
ReDim $aItems[$iCounter + 1][$aReturnProperties[0]] ; Process subfolders
If BitAND($iFlags, 1) = 1 Then
For $vFolder In $vFolder.Folders
$aTemp = _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
__OL_ArrayConcatenate($aItems, $aTemp, $iFlags)
Next
EndIf
Return $aItems
EndIf

EndFunc ;==>_OL_ItemFind

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

I have replaces the old function with the code you provided. the script is now running again. i will get back to you in an hour to see if its still running. Befor it usually crashes between 3000 and 5000 secounds. But the flow of mail os lower on a friday so if its till running when i go home in 1 hour. I will let you know on monday if its working. Thanx alot for all your help.

Link to comment
Share on other sites

You can only make sure that the new version works properly by sending a test mail to the mailbox you process.

The old version will surely crash whereas the new version should successfuly end. The new version will not process those mails that arrived during processing.

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

Well. It ran ALOT longer this time. But i still got the error. Cant say fir sure that its the same error though, bit it seems to be.

"Letar efter nya mail... C:\Program Files (x86)\AutoIt3\Include\OutlookEx.au3 (2674) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value

^ ERROR

>Exit code: 1 Time: 228714.483"

Link to comment
Share on other sites

Very, very strange.

I once again modified the _OL_ItemFind function. But now it's guessing then knowing where the problem might be.

Func _OL_ItemFind($oOL, $vFolder, $iObjectClass = Default, $sRestrict = "", $sSearchName = "", $sSearchValue = "", $sReturnProperties = "", $sSort = "", $iFlags = 0, $sWarningClick = "")

    Local $bChecked = False, $oItems, $aTemp, $iRecCounter = 0, $iCounter = 0, $oItem
    If $sWarningClick <> "" Then
        If FileExists($sWarningClick) = 0 Then Return SetError(2, 0, "")
        Run($sWarningClick)
    EndIf
    If $iObjectClass = Default Then $iObjectClass = $olContact ; Set Default ObjectClass
    ; Set default return properties depending on the class of items
    If StringStripWS($sReturnProperties, 3) = "" Then
        Switch $iObjectClass
            Case $olContact
                $sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber"
            Case $olDistributionList
                $sReturnProperties = "Subject,Body,MemberCount"
            Case $olNote, $olMail
                $sReturnProperties = "Subject,Body,CreationTime,LastModificationTime,Size"
            Case Else
        EndSwitch
    EndIf
    If Not IsObj($vFolder) Then
        $aTemp = _OL_FolderAccess($oOL, $vFolder)
        If @error Then Return SetError(3, @error, "")
        $vFolder = $aTemp[1]
    EndIf
    If ($sSearchName <> "" And $sSearchValue = "") Or ($sSearchName = "" And $sSearchValue <> "") Then Return SetError(1, 0, "")
    Local $aReturnProperties = StringSplit(StringStripWS($sReturnProperties, 8), ",")
    Local $iIndex = $aReturnProperties[0]
    If $aReturnProperties[0] < 2 Then $iIndex = 2
    If StringStripWS($sRestrict, 3) = "" Then
        $oItems = $vFolder.Items
    Else
        $oItems = $vFolder.Items.Restrict($sRestrict)
    EndIf
    Local $iItems = $oItems.Count
    Local $aItems[$iItems + 1][$iIndex] = [[0, $aReturnProperties[0]]]
    If BitAND($iFlags, 4) <> 4 And $sSort <> "" Then
        $aTemp = StringSplit($sSort, ",")
        If $aTemp[0] = 1 Then
            $oItems.Sort($sSort)
        Else
            $oItems.Sort($aTemp[1], True)
        EndIf
    EndIf
    For $i = 1 To $iItems
        $oItem = $oItems.Item($i)
        If $oItem.Class <> $iObjectClass Then ContinueLoop
        ; Get all properties of first item and check for existance and correct case
        If BitAND($iFlags, 4) <> 4 And Not $bChecked Then
            If Not __OL_CheckProperties($oItem, $aReturnProperties, 1) Then Return SetError(@error, @extended, "")
            $bChecked = True
        EndIf
        If $sSearchName <> "" And StringInStr($oItem.ItemProperties.Item($sSearchName).value, $sSearchValue) = 0 Then ContinueLoop
        ; Fill array with the specified properties
        $iCounter += 1
        If BitAND($iFlags, 4) <> 4 Then
            For $iIndex = 1 To $aReturnProperties[0]
                $aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value
                If @error Then Return SetError(4, @error, "")
                If BitAND($iFlags, 2) = 2 And $iCounter = 1 Then $aItems[0][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).name
            Next
        EndIf
        If BitAND($iFlags, 4) <> 4 And BitAND($iFlags, 2) <> 2 Then $aItems[0][0] = $iCounter
    Next
    If BitAND($iFlags, 4) = 4 Then
        $iRecCounter += $iItems
        ; Process subfolders
        If BitAND($iFlags, 1) = 1 Then
            For $vFolder In $vFolder.Folders
                $iRecCounter += _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
            Next
        EndIf
        Return $iRecCounter
    Else
        ReDim $aItems[$iCounter + 1][$aReturnProperties[0]] ; Process subfolders
        If BitAND($iFlags, 1) = 1 Then
            For $vFolder In $vFolder.Folders
                $aTemp = _OL_ItemFind($oOL, $vFolder, $iObjectClass, $sRestrict, $sSearchName, $sSearchValue, $sReturnProperties, $sSort, $iFlags, $sWarningClick)
                __OL_ArrayConcatenate($aItems, $aTemp, $iFlags)
            Next
        EndIf
        Return $aItems
    EndIf

EndFunc   ;==>_OL_ItemFind

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

Did you see anything "strange" on the console before it crashed?

If it crashes again this time we need as much information as we can get.

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

Just a quick update. The script have been running for 5 days now and it seems to be working. I dont know what you did, but it seems to be working :)

Thanx alot. I will keep this thread updates if there are any more strange errors. Thank You!

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...