Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

If @error = 0 after _OL_FolderAccess then the array is the expected result. Have alook at the help file to see what is returned by the function.

Did you pass "Gemensamma Mappar - *my emailadress* - Alla gemensamma mappar - folder1 - recption" to _OL_FolderAccess?

If yes then you can pass $array[1] (the folder object) to _OL_ItemFind to retrieve the calendar info.

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 am attempting to modify your example script to alert on new email messages that match a certain criteria.

#include <OutlookEX.au3>

;Set HotKey (Shift-Alt-E) to Exit the script
HotKeySet("+!e", "_Exit")

Run("C:Program FilesMicrosoft OfficeOffice14outlook.exe", "", @SW_MAXIMIZE)

Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")

While 1
WEnd

; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx
Func oOApp_NewMailEx($sOL_EntryId)

Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _
"From:    " & $oOL_Item.SenderName & @CRLF & _
"Subject: " & $oOL_Item.Subject & @CRLF & _
"Subject: " & $oOL_Item.BodyFormat & @CRLF & _
"Subject: " & $oOL_Item.HTMLBody & @CRLF & _
"Subject: " & $oOL_Item.Body)

EndFunc   ;==>oOApp_NewMailEx



Func _Exit()
Exit
EndFunc   ;==>_Exit

The code above is the example I am attempting to modify. Currently it works to alert on new emails. I have tried to include the text of the email but that is not displaying anything. The end goal would be to only display emails with a certain phrase in the body of the text.

Thank you

Link to comment
Share on other sites

I modified your code a bit. What's the value of BodyFormat you get?

#include <OutlookEX.au3>
;Set HotKey (Shift-Alt-E) to Exit the script
HotKeySet("+!e", "_Exit")
Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")
While 1
     Sleep(100)
WEnd

; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx
Func oOApp_NewMailEx($sOL_EntryId)
    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
    MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _
        "From: " & $oOL_Item.SenderName & @CRLF & _
        "Subject: " & $oOL_Item.Subject & @CRLF & _
        "BodyFormat: " & $oOL_Item.BodyFormat & @CRLF & _
        "HTMLBody: " & $oOL_Item.HTMLBody & @CRLF & _
        "Body: " & $oOL_Item.Body)
EndFunc ;==>oOApp_NewMailEx

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

BodyFormat is mostly 2. I am now seeing emails when they are HTML formatted. However if BodyFormat is 1 I never get anything but 0 returned in Body. Is this normal?

Also, I would like to throw a DASL search into this script so I am only seeing alerts for new emails with a certain string in them. Would something like this work:

#include 
;Set HotKey (Shift-Alt-E) to Exit the script
HotKeySet("+!e", "_Exit")
Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")
Global $s = "Invoice"
While 1
Sleep(100)
WEnd

; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx
Func oOApp_NewMailEx($sOL_EntryId)
Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
$sFilter = "@SQL=""urn:schemas:httpmail:textdescription"" ci_phrasematch '" & $s & "'"
$aResult = _OL_ItemSearch($oOApp, "*Inbox", $s, "EntryID,Subject,urn:schemas:httpmail:textdescription")
If @error Then
MsgBox(16, "Error", "Error! @error = " & @error & ", @extended = " & @extended)
Else
MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _
"From: " & $oOL_Item.SenderName & @CRLF & _
"Subject: " & $oOL_Item.Subject & @CRLF & _
"BodyFormat: " & $oOL_Item.BodyFormat & @CRLF & _
"HTMLBody: " & $oOL_Item.HTMLBody & @CRLF & _
"Body: " & $oOL_Item.Body)
EndIf

EndFunc ;==>oOApp_NewMailEx

Func _Exit()
Exit
EndFunc ;==>_Exit

Thank you

Link to comment
Share on other sites

BodyFormat: 0 = Unspecified Format, 1 = Plain Format, 2 = HTML

If BodyFormat is 2 the mail body is to be found in property HTMLBody, else in Body.

Which version of Outlook to you run?

You get an event for every mail that you receive. When the mail arrives the event is triggered and you get the EntryID of the new mail passed as an argument.

Therefore there is no need to use _OL_ItemSearch to search the whole Inbox.

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 receiving an HTML formatted email (BodyFormat = 2) I get the contents of the email in HTMLBody. When BodyFormat = 1 I am not getting anything in Body, all I get returned is 0.

Yeah, I was thinking after I posted that searching the entire inbox after receiving the alert was a waste. BTW I am using Outlook 2010.

Thank you

Edited by chaoticmindz
Link to comment
Share on other sites

You could call _OL_ItemGet to get all properties of the item and display it using _ArrayDisplay.

What do you get?

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

Below is code modified

#include 

;Set HotKey (Shift-Alt-E) to Exit the script
HotKeySet("+!e", "_Exit")

Global $oOApp = ObjCreate("Outlook.Application")
Global $test = ObjEvent($oOApp, "oOApp_")

While 1
Sleep(100)
WEnd

; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx
Func oOApp_NewMailEx($sOL_EntryId)
Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
Local $allProperties = _OL_ItemGet($oOApp, $oOL_Item)
_ArrayDisplay($allProperties)
EndFunc ;==>oOApp_NewMailEx

Func _Exit()
Exit
EndFunc ;==>_Exit

I am getting:

C:\Program Files\AutoIt3\Include\OutlookEX.au3 (2804) : ==> The requested action with this object has failed.:

$aProperties[$iCounter][1] = $oProperty.value

$aProperties[$iCounter][1] = $oProperty.value^ ERROR

Link to comment
Share on other sites

Which version of the UDF do you use?

Which version of AutoIt do you use?

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

Just to be sure. If you look at the first few lines of the UDF you see UDF Version ...: 0.9.0.0?

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 will check as soon as I'm in my office again and hopefully post a solution.

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've enhanced the example script. Can you try this version?

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

; *****************************************************************************
; Example Script
; Handle Outlook NewmailEX event when a new mail arrives.
; 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 $oOApp = _OL_Open()
Global $test = ObjEvent($oOApp, "oOApp_")

While 1
    Sleep(50)
WEnd

Func oOApp_NewMailEx($sOL_EntryId)

    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
    Local $aProperties = _OL_Itemget($oOApp, $oOL_Item)
    _ArrayDisplay($aProperties)

EndFunc   ;==>oOApp_NewMailEx

Func _Exit()
    _OL_Close($oOApp)
    Exit
EndFunc   ;==>_Exit
Edited by water

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

That's great.

_OL_Open starts the COM error handler under the cover and that's what solved the problem.

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

Hi water,

I'm trying to figure out what permissions I need to set on another mailbox to be able to create items in their calendar. Currently the only way I can successfully create an item in another user's mailbox is if my account has full access permission on the other mailbox. The script i'm using is below:

Global $cal = _OL_FolderAccess($oOL, "Secondary Sourcing CalendarCalendar", $olFolderCalendar)
; Create an appointment and set some properties
$oItem = _OL_ItemCreate($oOL, $olAppointmentItem, $cal[1], "", _
"Subject=" & GUICtrlRead($subject), "Start=" & GUICtrlRead($startDate) & " " & GUICtrlRead($startTime) & ":00", _
"Duration=" & $duration, "Location=" & GUICtrlRead($location), _
"RequiredAttendees=" & $emailAddr, "MeetingStatus=1", "Body=" & GUICtrlRead($notes))
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olResource, $oLoc)
_OL_ItemSend($oOL, $oItem)
; Close connection to Outlook
_OL_Close($oOL)

The mailbox in question is the "Secondary Sourcing Calendar" mailbox. I tried adding the create item permission on the calendar as well as a few other permissions, and nothing works unless i have full access permission to the mailbox.

Also, in the _OL_ItemRecipientAdd line if the added user is a specific mailbox it will get the invitation, but it displays the subject line as "Secondary Sourcing Calendar" (which is the mailbox sending the invitation) instead of the subject defined in the $oItem object. It only does that for one mailbox, any of the others work as expected. Any thoughts? UDF version is 0.7.1.1

Link to comment
Share on other sites

Ad 1) I'm not very firm with Outlook/Exchange permissions. But what I've read on Google it should be possible to limit the permissions of a delegate to the calendar only without the need for full access. Will have to do some more searching ...

Ad 2) I have no idea why this happens. You could download the latest 0.9.0.0 version and give it a try. If you still get this strange result then add "_OL_ErrorNotify(2)" at the top of your script (but after the #include directives) an see if you get any COM error messages.

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

  • 2 weeks later...

Ad 1) I'm not very firm with Outlook/Exchange permissions. But what I've read on Google it should be possible to limit the permissions of a delegate to the calendar only without the need for full access. Will have to do some more searching ...

I think there may be an issue with your _OL_FolderAccess function, I removed all permissions from the mailbox except the ability to create items in the calendar folder, and created the object manually using the code below instead of using the FolderAccess function:

$nameSpace = $oOL.GetNamespace("MAPI")
$calName = $nameSpace.CreateRecipient("Secondary Sourcing Calendar")
$calName.Resolve
$calFolder = $nameSpace.GetSharedDefaultFolder($calName, $olFolderCalendar)

And this worked without incident. I used the link here to get some information on the procedure in case it helps anybody else http://msdn.microsoft.com/en-us/library/office/ff869575.aspx

Ad 2) I have no idea why this happens. You could download the latest 0.9.0.0 version and give it a try. If you still get this strange result then add "_OL_ErrorNotify(2)" at the top of your script (but after the #include directives) an see if you get any COM error messages.

I found this was not an issue with the autoit script. On the exchange 2010 console there are two settings in the properties of the resource mailbox under Properties > Resource Information that need to be adjusted. "Delete the subject" and "Add the organizer's name to the subject" should be unchecked. Edited by benjbong
Link to comment
Share on other sites

Ad 1) I had a quick look at _OL_FolderAccess and I got the impression that the function does the same as your code. Will have a deeper look tomorrow.

The only difference I see is that your code above only accesses the Calendar whereas your code in post #597 accesses a subfolder of the Calendar.

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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