Long time lurker here, I've been able to solve problems by searching posts on the forum in the past but now I'm stuck !
I'm trying to write a script which would monitoring when a user sends a new email through Outlook app, and get those specific informations
- recipient e-mail address
- subject
So far, I have this code on a timer :
Code: Select all
IfWinActive, Message (HTML) ; only way I have found to see when a user is redacting a new email
{
active_window_id := WinExist("A")
address:=
subject:=
loop ; loops continuously, until the user has entered the recipient's email address
{
IfWinNotExist, ahk_id %active_window_id%
return
olApp := ComObjActive("Outlook.Application")
olEmail := olApp.ActiveWindow.CurrentItem
for olRecipient in olEmail.Recipients
address:=olRecipient.Address
subject:=olEmail.subject
if address=
{
sleep 500
continue
}
else
break
}
}
However, this has proven unreliable, since opening a received email will trigger the same behavior by the script.
I am wondering if someone could help me to monitor when a user sends an email with ItemSend event https://docs.microsoft.com/en-us/office/vba/api/outlook.application.itemsend, or any other reliable way for that matter.
Thank you