Jump to content

OutlookEX - Find unread mails and get the body


Go to solution Solved by legend,

Recommended Posts

  • Solution
#include <OutlookEX.au3>
;------------------------------------------------------------------------------------------------------------------------------------------------
; Get/List all unread mails from the folder (R_Inbox)

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
;------------------------------------------------------------------------------------------------------------------------------------------------
$aItems = _OL_ItemFind($oOutlook, "*\", $olMail, "[UnRead]=True", "Subject", "test", "EntryID,Subject", "", 1)

If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf
;_OL_Close($oOutlook)

Local $numberOfUnRead = UBound($aItems, $UBOUND_ROWS) - 1               ; Gets the number of unread emails

; Get the mail headers of the first mail
Global $sMailHeaders = _OL_ItemGet($oOutlook, $aItems[2][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet", "MAIL HEADERS WITH THE SUBJECT OF:" & @CRLF & "'" & $aItems[1][1] & "'." & @CRLF & @CRLF & $sMailHeaders)

I can get the header / subject, but i'm not sure how I would actually get the body of the unread mails, does anybody know? :)

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