Jump to content

[SOLVED] How to change the status of an email from unread to read


Recommended Posts

Good afternoon, I am in need of some help. I am sure this is a stupid question requiring only one or two lines of code. However, I would greatly appreciate the help I cannot figure this out. I also tried searching for the answer on the internet but no one except me apparently seems to be having a hard time figuring this out and or is asking about it. 

I simply want to change the "status" of an email from unread to read once I have processed it. My code is over 500 lines and I would like not to clutter this post with it. Assume I have all my includes and connections properly defined and stuff. 

Here is the bit of code where I am trying to change the email that was used from unread to read:

Func ChangeEmailStatus()

    ;*******************************************************************************
    ; changes the status of an email from unread to Read
    ;*******************************************************************************
    Local $iRows = UBound($aItems, $UBOUND_ROWS)
    MsgBox("", "Number of Unread emails (Before Change)", $iRows)

    _OL_ItemModify($oOutlook,$aItems[$i][0], Default, "Read=True")

    MsgBox("", "Array Display 1", $aItems[1][0])
    MsgBox("", "Array Display 2", $aItems[2][0])

    Local $iRows = UBound($aItems, $UBOUND_ROWS)
    MsgBox("", "Number of Unread emails (After Change)", $iRows)
    
EndFunc

 

Edited by nooneclose
Link to comment
Share on other sites

What is the value of @error and @extended after _OL_ItemModify?
Every function returns information when there was an error.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

BTW: The property to set is named "UnRead".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water I am not getting an error message?  Once the code starts the second loop the same email info is used again. My code is not correctly changing the email that was used from unread to read. 

 

Func ChangeEmailStatus()

    ;*******************************************************************************
    ; changes the status of an email from read to unread or vice versa
    ;*******************************************************************************
    ConsoleWrite(@CRLF)
    ConsoleWrite(@CRLF)
    ConsoleWrite(@CRLF)

    Local $iRows = UBound($aItems, $UBOUND_ROWS)
    MsgBox("", "Number of Unread emails (Before Change)", $iRows)

    _OL_ItemModify($oOutlook,$aItems[1][0], Default, "Unread=True")
    ConsoleWrite("hello? Test?" & @CRLF)

    MsgBox("", "Array Display 1", $aItems[1][0])
    ;MsgBox("", "Array Display 2", $aItems[2][0])

    Local $iRows = UBound($aItems, $UBOUND_ROWS)
    MsgBox("", "Number of Unread emails (After Change)", $iRows)
    ConsoleWrite(@CRLF)
    ConsoleWrite(@CRLF)
    ConsoleWrite(@CRLF)
EndFunc

 

Edited by nooneclose
Link to comment
Share on other sites

To get the same result when moving from "Read=True" to "Unread=???" which value does ??? need to have? ;)
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks :) 

You know some days I wonder why I even try haha. It works now, thank you @water  

Func ChangeEmailStatus()

    ;*******************************************************************************
    ; changes the status of an email from Unread to Read
    ;*******************************************************************************
    _OL_ItemModify($oOutlook,$aItems[1][0], Default, "Unread=False")

EndFunc

 

Edited by nooneclose
Link to comment
Share on other sites

That's it :thumbsup: You get smarter every day :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

×
×
  • Create New...