Sign in to follow this  
Followers 0
idanzzz

reading subject in outlook

18 posts in this topic

Hi all,

i have a script that at the moment will perform a certain task when the script is run for outlook.

For example there are 5 unread emails in a certain folder it will then loop through performing specific functions for each email however what i need to be able to do is to grab specific information from the subject and paste that in.

So the subject will look like this - FW: Complete: test1 update: ORD0000xxxxxxxx: AVC: Connect: OWO_xxxxxx: ASI000000220777

I want to be able to grab the part after OWO_ i want the xxxxxx part to be pasted into a form however not sure how to capture the information from the subject field and paste it in?

any help would be appreciated!!!!!

Share this post


Link to post
Share on other sites



Please have a look at my OutlookEX UDF (for download please see my signature).


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

I have 95% of the script working doing what i need however i need it to work from a specific FOLDER and not my main mailbox. I just need to be able to have the script perform the function i need there is mail in a certain folder. If possible can you show or modify the part you think i need to fix up? all help is appreciated!!!!!

#include <OutlookEX.au3>

$ol = ObjCreate("Outlook.Application")
$ns = $ol.GetNameSpace("MAPI")
$MyFolder = ObjCreate("Outlook.MAPIFolder")
$objns = ObjCreate("Outlook.Namespace")
Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")
$WRACT_NBNinbox = $ns.Folders("Mailbox - WRActivations_NBN").folders("Inbox").folders("NBN").folders("Completed")
While 1
WEnd
HotKeySet("{ESC}", "Terminate")

Func oOApp_NewMailEx($sOL_EntryId)

    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
    $count = $WRACT_NBNinbox.Items.Count
    For $position = $count To 1 Step - 1
        MouseClick("left",69,388,1)
        ;REST OF SCRIPT ACTIONS
        
        Next


EndFunc   ;==>oOApp_NewMailEx

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Share this post


Link to post
Share on other sites

Do you want to process all unread mails currently in your folder or do you want to process new mails arriving while your script is running?


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

i want to be able to process all unread mails currently in a folder - as outlook will have a rule to move certain emails to folders and what i want to do is run the script every few hours to process those emails.

its currently only doing the function when new mail go into my mailbox but i want it for a certain folder and want to take a specific part of the subject field and use that in my function.

Share this post


Link to post
Share on other sites

Replace "*Outlook-UDF-Test" with the name of your folder.

#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
Global $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "Subject,EntryID")
_OL_Close($oOutlook)

Now you've got an array with the Subject and EntryID of all unread mails.

How do you want to process this mails (save, print ...)?


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

ok so essentially i will have 100 unread emails in a folder and i want to run the script which will then read the first email and perform the function required and i need it to paste a reference number from the subject into a field.

it will then move onto the next email and do the same function and so on........till its gone to the last email then stop script

Share this post


Link to post
Share on other sites

My code gives you the subject in

$aItems[$i][0]

$i is the index for the row in the array.


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

ok i can't quite understand what i am doing wrong here - newbie @ Autoit :( i had the tooltip work whenever an email would reach my inbox and it would display the time and date of the email. however i need it to be able to show me the time and date of the oldest email in a folder and i dont know if i am even heading in the right direction :(

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>
#include <Date.au3>

Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")
Global $oOutlook = _OL_Open()
Global $aItems = _OL_ItemFind($oOutlook, "*\NBN\Completed", $olMail, "[UnRead]=True", "", "", "Subject,EntryID")
_OL_Close($oOutlook)

HotKeySet("{ESC}", "Terminate")
dim $balloon2
dim $balloon


While 1

    oOApp_NewMailEx($sOL_EntryId)

    ExitLoop

wend
    

func oOApp_NewMailEx($sOL_EntryId)
    $count = $oOutlook.Items.Count
    For $position = $count To 1 Step - 1
    Local $oOL_Item = $oOApp.Session.GetItemFromID($aItems, Default)
    $balloon = $oOL_Item.Receivedtime
    $balloon2 = StringMid($balloon, 7, 2) & "/" & StringMid($balloon, 5, 2) & "/" & StringLeft($balloon, 4) & " - " & StringMid($balloon, 9, 2) & ":" & StringMid($balloon, 11, 2) & ":" & StringMid($balloon, 13, 2)
    ;If $balloon2 <> @HOUR Then
        ToolTip ($balloon2, 800 , 10, "Order Approaching SLA", 2, 1)
    Next
    
EndFunc

;Func _WinWaitActivate($title,$text,$timeout=0)
;   WinWait($title,$text,$timeout)
;   If Not WinActive($title,$text) Then WinActivate($title,$text)
;   WinWaitActive($title,$text,$timeout)
;EndFunc

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

i keep getting this error come up -

post-80210-0-09089700-1369721351_thumb.j

Share this post


Link to post
Share on other sites

I'm quite busy at the moment but hope to post an example this weekend.

1 person likes this

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

Do you need to combine processing of Outlook events (means: run a function when a new mail arrives) plus processing all unread mails in one script?


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

sorry for the delay - i need it to be able to just process un-read mail (oldest email sitting in a certain dropbox) once that mail is moved to another folder then the timer moves to the next oldest email in the folder and displays how long it has been sitting there for.

i ran a test in the above code to see how it would work when new mail arrived and it worked fine, just don't know how to get it to work on unprocessed emails.

any help is appreciated :) cheers - once again yes i am a newbie at this lol

Share this post


Link to post
Share on other sites

This always returns the Subject/ReceivedTime of the oldest mail:

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
Global $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[UnRead]=True", "", "", "Subject,EntryID,ReceivedTime", "[ReceivedTime]")
_ArrayDisplay($aitems)
MsgBox(0, "", "Oldest Mail: " & @CRLF & "Subject: " & $aitems[1][0] & @CRLF & "Received on: " & StringRegExpReplace($aitems[1][2],"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})","$1/$2/$3 $4:$5:$6"))
_OL_Close($oOutlook)

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

sorry in the context of my code where would i fit this?

thanks for your help thus far!!!

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

actually i figured it all out (Thanks to your help) and works great with the msgbox however i need it to be put in a tool tip if possible? i am not sure how to translate the msgbox code into a tooltip? you able to assist with that

nearly there :D

Edited by idanzzz

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Something like this?

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
Global $aItems = _OL_ItemFind($oOutlook, "*\Posteingang", $olMail, "[UnRead]=True", "", "", "Subject,EntryID,ReceivedTime", "[ReceivedTime]")
If $aItems[0][0] > 0 Then
    ToolTip("Oldest Mail: " & @CRLF & "Subject: " & $aItems[1][0] & @CRLF & "Received on: " & StringRegExpReplace($aItems[1][2], "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6"))
    Sleep(5000) ; Display the TooLTip for 5 seconds
EndIf
_OL_Close($oOutlook)
Edited by water

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

champion :) that worked perfectly!!!!!

thanks for your help water!!!!!

Share this post


Link to post
Share on other sites

Glad to be of service :D


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

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