Jump to content

read mail message in outlook pane - (Moved)


Recommended Posts

Does this mean you modified your script or the OutlookEX UDF?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

I see. So there is no need to update my OutlookEX UDF :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

yeah you are the expert.:D hehe

Just to check with you,

i have a 3rd party program installed in outlook, there will be an addition text added in mailsubject title and mailbody message whenever the send/reply/forward etc mail button is hit.

with just the codes, subject and body (eg mailbox.subject), it does not capture the addition text.

What i am trying to achieve is when the send button is hit, the addition text will be capture in subject and body as well, so the result can be display in my 2d arraylist.  can this possibly be done? 

 

 

 

 

Link to comment
Share on other sites

To act on the send button you need to use "Events".
Please have a look at my OutlookEX example scripts thread, example: _OL_Example_SentMail_Event.au3

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

saw your example scripts but the scripts event has to check the send folder, i am actually automating in offline so the mail messages are probably siting in outbox. so just checking are there any other options to check the sent message without checking folders? do we have other events or methods to check on  subject and body via the send buttons?

 

 

 

 

 

 

Link to comment
Share on other sites

The send event of the mailitem would be another option (which I have not used yet):  https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.send(even)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

This example script grabs all "Send" events, checks for mails and modifies the subject before sending the mail.

#include <OutlookEX.au3>

; *****************************************************************************
; Example Script
; Handle Outlook event when a new item is being sent.
; This script checks for mail items and changes the subject before the mail is
; being sent.
; This script loops until Shift-Alt-E is pressed to exit.
; *****************************************************************************
HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script
MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!")

Global $oApp = ObjCreate("Outlook.Application")
Global $oEvent = ObjEvent($oApp, "_oItems_")

While 1
    Sleep(50)
WEnd

; Outlook 2007 - ItemSend event - http://msdn.microsoft.com/en-us/library/bb147641%28v=office.12%29.aspx
Volatile Func _oItems_ItemSend($oItem, $bCancel)

    #forceref $bCancel
    $bCancel = False
    If $oItem.Class = $olMail Then
        $oitem.Subject = "Modified by AutoIt script: " & $oitem.Subject
        $oItem.Save()
    EndIf

EndFunc   ;==>oItems_ItemSend

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 water, you're a genius.

however, when i click on send button,  i have installed a 3rd party program that will prompts and do some action before the mail is sent out. hence, somehow or rather from the 3rd party program running, i am unable to return email message body $mailitem.body from outlook to msg box nor array, any advise? it is blank.

The script above works if the handler runs without the 3rd party program prompts. i could get the return email message body. 

$array[$i][1] = $mailitem.subject
$array[$i][2] = $mailitem.body

$hashsubject = _crypt_hashdata($mailitem.subject,$CALG_MD5)
$hashbody = _crypt_hashdata($mailitem.body,$CALG_MD5)

$array[$i][3] = $hashsubject
$array[$i][4] = $hashbody
$mailitem.save()

_Arraydisplay($array)

 

Edited by devilburnz
Link to comment
Share on other sites

Did you try the HTMLBody property?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Seems the plugin interferes with the event handler.
Hard to tell how to solve this problem.

Can you please tell me what you try to do with your script? Maybe there is a better way to do what you want to do ...
 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Quote

oh i trying to send an email so what written by the user in the subject and mail body should be stored into array.

Idea 1: Add another recipient so you get a copy of the sent mail.
Idea 2: Create an Outlook rule that creates a copy of the mail when some conditions are met (see _OL_RuleAdd.au3 for an example)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

16 hours ago, water said:

Idea 1: Add another recipient so you get a copy of the sent mail.
Idea 2: Create an Outlook rule that creates a copy of the mail when some conditions are met (see _OL_RuleAdd.au3 for an example)

Maybe a little hard.

i have figured out my outlook behavior, when the send button is clicked, the 3rd party program auto starts and it takes about 3-5 seconds for the message body to goes blank and the mail will be send after. so after the send click starts, it probably my chance to capture the message body and store it quickly without update the array.

so just checking can the event handler capture the information after the send button is click within 3-5 seconds and stores the message body into array without updating the message/array after the mail has send out? 

 

 

Edited by devilburnz
Link to comment
Share on other sites

The script I posted above at maximum delays the processing of the event by 50 milliseconds.
So the processing should be done within the 3-5 seconds you mentioned.

Can you please post your script so I can check if there are any further delays?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

when the 3rd party program pops out, the program will add the additional text to the mail body(which is i want to capture the mail body text).

4-5 seconds later, the 3rd party running program pops out auto exit, the mail body message changes to blank and mail is send out all together simultaneously. 

 i did try to put up the delay up to 8 seconds and i don't think the issue of delay will help because when the 3rd party program and new mail exits, the mailbody will be updated to blank. 

my sample codes is below

Global $oApp = ObjCreate("Outlook.Application")
Global $oEvent = ObjEvent($oApp, "_oItems_")
global $array[1][2]

sendmail()
_arraydisplay($array)

Func sendmail() ; the new email is opened
send("mail testing")
sleep(8000)
controlclick("Untitled","","Button1") ;This is the action to trigger the send event
Endfunc

; Outlook 2007 - ItemSend event - http://msdn.microsoft.com/en-us/library/bb147641%28v=office.12%29.aspx
Volatile Func _oItems_ItemSend($oItem, $bCancel)

    #forceref $bCancel
    $bCancel = False
    If $oItem.Class = $olMail Then
        $array[$i][2] = $oItem.body 
        $oItem.Save()
    EndIf

EndFunc   ;==>oItems_ItemSend

 

Edited by devilburnz
added arraydisplay
Link to comment
Share on other sites

The Send(8000) does not help because the send event gets triggered with the conrolclick.

I would add myself to the recipients. Add a second script to wait for a newmail event and process the subject and body from this mail in the inbox.
You can identify this mail by the text that gets added by your plugin.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...