Jump to content
nooneclose

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

Recommended Posts

nooneclose

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

Share this post


Link to post
Share on other sites
water

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 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
nooneclose

@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

Share this post


Link to post
Share on other sites
water

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

  • Haha 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
nooneclose

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

Share this post


Link to post
Share on other sites
water

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

  • Thanks 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


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

  • Similar Content

    • gahhon
      By gahhon
      Hi,
      I have a program that is read data from the .txt file, since the .txt file is only readable, viewable and editable for the admin user.
      But how could I lock it with password, or some other technique that can helps to achieve this?
      Thanks for the advanced information.
    • gahhon
      By gahhon
      Hi,
      How can I the trigger the another button functions without waiting the previous function to finish execute?
      Any advise?
      I couldn't find any relevant topics via google.
      Thanks a lot.
    • SharpDressedMan
      By SharpDressedMan
      Hi all,
      I need to use ControlMove() on some controls of a hidden GUI window.
      This works properly on a GUI window created with default style, but does not work on a GUI window created with style $WS_OVERLAPPEDWINDOW
      func GUItest($bOverlapped) $m = GUICreate("test", 200, 100, -1, -1, $bOverlapped ? $WS_OVERLAPPEDWINDOW : -1) $g = GUICtrlCreateButton("test", 0, 0) ControlMove($m, "", $g, 30, 30) GUISetState() endfunc GuiTest(false) ; button 'test' properly moved to (30,30) GuiTest(true) ; button 'test' not moved and still sitting at (0,0) Any reason for this unexpected behavior ?
      Any workaround to fix this ?
      Thanks for any help
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Friends,
      I am having a requirement where i have to automate outllook.I have to send mail using outlook.Whe i went through the forum i got OutLookEx.au3 but when i am trying to use this i am getting error can anyone help me in using this? @water
    • 2Toes
      By 2Toes
      Hi all..
      I'm having slight issue that has be a bit puzzled.
      I have an Input control.. After a certain function runs, it Disables that Input control, and sets it to ReadOnly.
      When running another certain function, it re-Enables that Input control, and sets the style back to Default.
      Which does work, however, when typing into the Input control after re-Enabling it, the text appears as a light gray color, rather than its original black color.
      I'm sure there's a simple solution here.. But what that is, appears to be beyond me.
      Here is a simplified example code:
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 245, 215, 192, 124) Global $disableBTN = GUICtrlCreateButton("Disable", 32, 64, 75, 25) Global $enableBTN = GUICtrlCreateButton("Enable", 128, 64, 75, 25) Global $Input1 = GUICtrlCreateInput("", 32, 120, 169, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $disableBTN disable() Case $enableBTN enable() EndSwitch WEnd Func disable() GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetStyle($Input1, $ES_READONLY) EndFunc Func enable() GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetStyle($Input1, $GUI_SS_DEFAULT_INPUT) EndFunc  
      Any help would be greatly appreciated
      Thank you in advance!
×