Sign in to follow this  
Followers 0
NTBM

get date/time of current outlook item

5 posts in this topic

i am trying to get the current date and time of a selected email. This will be used later for saving it out to a .msg file.

i have the script below that will list all the receivedtime for messages in the inbox, but what i am trying to achieve is to switch to outlook (dont care what folder the user is in) and get the timestamp for the item that is selected on their screen.

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",1)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
#include <date.au3>
#include <IE.au3>
WinWait("Outlook","")
If Not WinActive("Outlook","") Then WinActivate("Outlook","")
    
WinWaitActive("Outlook","")
Global $olFolderInbox = 6, $sSender = "anyone@anywhere.net.au", $sSubjectSTOP = "sSENTRY STOP", $sSubjectSTART = "sSENTRY START", _
$sSTime, $sSFlag, $receive

$o_Outlook = ObjCreate("Outlook.Application")
$oNameSpace = $o_Outlook.GetNameSpace("MAPI")
$oInbox = $oNameSpace.GetDefaultFolder($olFolderInbox)
$oItems = $oInbox.Items

For $oItem In $oItems
    $receive = $oItem.ReceivedTime
    MsgBox(0,'',"The Date is:" & $receive)
Next

Share this post


Link to post
Share on other sites



Hi NTBM

Do you have a Solution for your problem?

I also try to get the selected mail item in every folder (not only the inbox)

Thanks for your reply

Best regards

Veronesi

Share this post


Link to post
Share on other sites

Hi Veronesi,

I am not at my PC at the moment (actually I am on Lanzarote until Sunday :) ). I will answer your question on Monday.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi water

Thanks for your reply. I wish you a nice holiday :-)

I need the sender email, the email body text and the subject of the currently selected mail item.

Independently of the folder in which it is. (Outbox, Inbox, Custom folder...)

I never worked with the outlook UDF because I ONLY need this function.

I don't want to include the whole UDF...

But if it's working with the outlook UDF, then I can try to "export" the used functions in my program.

Thanks for your help!

Best regards

Veronesi

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi water!

I'm very sorry that I disturb you.

But I think, I have the solution with your Outlook UDF.

#include <OutlookEx.au3>
#include <Array.au3>
$oOutlook = _OL_Open()
$aReturn = _OL_FolderSelectionGet($oOutlook)
$aReturn = _OL_ItemGet($oOutlook, $aReturn[1][1]) ;[1][1] = ID of selected Mail
_ArrayDisplay($aReturn)
;Body = [9][1]
;SenderEmailAddress = [64][1]
;TaskSubject = [79][1]
_OL_Close($oOutlook)

Edit:

Hi NTBM

Following a sample to get the date / time of the currently selected mail item.

Independant of the mail folder in which this item is. Hope, this helps

#include <OutlookEx.au3>
$oOutlook = _OL_Open()
$aReturn = _OL_FolderSelectionGet($oOutlook)
$aReturn = _OL_ItemGet($oOutlook, $aReturn[1][1]) ;[1][1] = ID of selected Mail
$sDate = $aReturn[18][1]
$sDate2 = StringMid($sDate, 7, 2) & "." & StringMid($sDate, 5, 2) & "." & StringLeft($sDate, 4) & " - " & StringMid($sDate, 9, 2) & ":" & StringMid($sDate, 11, 2) & ":" & StringMid($sDate, 13, 2)
MsgBox(64, "Creation Time", $sDate2)
_OL_Close($oOutlook)

OutlookEx.au3 from

Best regards

Veronesi

Edited by veronesi

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
Sign in to follow this  
Followers 0