Jump to content

OutlookEX UDF - Help & Support (II)


water
 Share

Recommended Posts

What do you get if you try:

#include <OutlookEX.au3>
#include <Array.au3>
$oOutlook = _OL_Open()
ConsoleWrite("_OL_Open: " & @error & @LF)
$Local_Folder = _OL_FolderAccess($oOutlook, "Path\To\Folder\With\Mail\Items")
ConsoleWrite("_OL_FolderAccess: " & @error & @extended & @LF)
$listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "", "", "", "UnRead,EntryID,SenderEmailAddress,Subject,Body", "", 4)
ConsoleWrite("_OL_ItemFind: " & @error & @LF)
ConsoleWrite("# of records: " & $listofmail)

This should return a count of found records.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

But there should be a line "# of records: n"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

So the count is correct? Is this mail item read or unread?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Looks good too.

How about this:

#include <OutlookEX.au3>
#include <Array.au3>
$oOutlook = _OL_Open()
ConsoleWrite("_OL_Open: " & @error & @LF)
$Local_Folder = _OL_FolderAccess($oOutlook, "Path\To\Folder\With\Mail\Items")
ConsoleWrite("_OL_FolderAccess: " & @error & @extended & @LF)
$listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olMail, "", "", "", "UnRead,EntryID")
ConsoleWrite("_OL_ItemFind: " & @error & @LF)
_ArrayDisplay($listofmail)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Very strange!

Some more testing will be needed - tomorrow. Because I'm not in my office any more.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

After line

$oItems = $vFolder.Items.Restrict($sRestrict)
can you please insert
MsgBox(0, "", "Items: " & $oItems.Count)
in function _OL_ItemFind an rerun the last script from post #27?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 still get this in the console:

_OL_Open: 0
_OL_FolderAccess: 00
_OL_ItemFind: 0

If I put the msgbox where you said to, no message appears. It is not dropping into the else statement as we don't appear to have any restrictions set. ?

The below script returns the message box with the correct number of items in the folder:

If StringStripWS($sRestrict, 3) = "" Then
$oItems = $vFolder.Items
msgBox(0,"",$oItems.Count)
Else
$oItems = $vFolder.Items.Restrict($sRestrict)
EndIf
Edited by idahoguy4life
Link to comment
Share on other sites

I figured it out!

You got me thinking it must not be the right class...so I commented out

If $oItem.Class <> $iObjectClass Then ContinueLoop

and my array returned the items.

Then I simply requested it write what $oItem.Class was and discovered the items in the folder were being stored as

$olPost !

Changing my script to below showed my array properly:

#include "OutlookEX.au3"
#include <Array.au3>
$oOutlook = _OL_Open()
ConsoleWrite("_OL_Open: " & @error & @LF)
$Local_Folder = _OL_FolderAccess($oOutlook, "Path\To\Public\Folder")
ConsoleWrite("_OL_FolderAccess: " & @error & @extended & @LF)
$listofmail = _OL_ItemFind($oOutlook, $Local_Folder[1], $olPost, "", "", "", "UnRead,EntryID")
ConsoleWrite("_OL_ItemFind: " & @error & @LF)
_ArrayDisplay($listofmail)

Thank you so much for helping me dig through this. You are a genius :)

The rest should be simple enough :-S

Edited by idahoguy4life
Link to comment
Share on other sites

I'm glad you could figure it out!

You found a bug in _OL_ItemFind because the count flag doesn't check the object class as the function does when the flag isn't set. That's why we got different results.

I will change the function and hope to post an updated version quite soon.

Thanks!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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 again. Just so you know. I got the public folders script to work and i can now access all the calenders. Thank you for all your help :)

Now i have just a quick question. Is there any way to change the defualt messageclass for a specific folder? Ive done a custom form region that i want to deploy and use as standard form for all appointments. I know how to do it manually in outlook, but i would like to to it with script.

Link to comment
Share on other sites

I'm not familiar with custom forms. How do you do it manually?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Custom forms or form regions are customized windows in Outlook. You could for example extend the standard contact forms with more fields if you like. Say that i want to add contacts and i want to add what size of pants that my contact has, i can add another field called "Butt size" or somthing. Then i can save and publish this as a custom form. You can also make a brand new form and save it as a entire new messageclass. The standard messageclass for appointments is "IPM.appointment". But i could switch this to my own custom form.

So if you go to "all folders" and then bring up the properties for the "Calender" folder. There is a field called

"When posting to this folder, use: ". There you can choose what message class you like to use when posting in the calender. You can replace the standard IPM.appointment to you own custom form. And thats what i would like to do. I found this code in VB that seesm to be doing somthing of the sort. Pehaps you can understand it better then me.

http://www.outlookcode.com/codedetail.aspx?id=1594

Link to comment
Share on other sites

Looks good, will give it a try.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Could you please give this function a try?

; #FUNCTION# ====================================================================================================================
; Name ..........: _OL_FolderClassSet
; Description ...: Set the default form (message class) for a folder
; Syntax.........: _OL_FolderClassSet($oFolder, $sMsgClass)
; Parameters ....: $oFolder   - Folder object of the folder to be changed as returned by _OL_FolderAccess
;                 $sMsgClass - New message class to set for the folder. Has to start with the DefaultMessageClass e.g. IPM.NOTE.mynote for class IPM.NOTE
; Return values .: Success - 1
;                 Failure - Returns 0 and sets @error:
;                 |1 - $oFolder is not an object
;                 |2 - message class IPM.NOTE can not be default for any folders
;                 |3 - message class IPM.POST can only be default for mail/post folders
;                 |4 - New message class has to start with the DefaultMessageClass e.g. IPM.NOTE.mynote for class IPM.NOTE
;                 |5 - Parameter $sMsgClass is invalid. A required period is missing
;                 |6 - Error setting folder property. @extended is set to the COM error
; Author ........: water
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.outlookcode.com/codedetail.aspx?id=1594
; Example .......: Yes
; ===============================================================================================================================
Func _OL_FolderClassSet($oFolder, $sMsgClass)
    If Not IsObj($oFolder) Then Return SetError(1, 0, 0)
    Local $oPropertyAccessor, $iLoc
    Local Const $PR_DEF_POST_MSGCLASS = "http://schemas.microsoft.com/mapi/proptag/0x36E5001E"
    Local Const $PR_DEF_POST_DISPLAYNAME = "http://schemas.microsoft.com/mapi/proptag/0x36E6001E"
    Switch StringLeft(StringUpper($sMsgClass), 8)
        Case "IPM.NOTE" ; cannot be default for any folder
            Return SetError(2, 0, 0)
        Case "IPM.POST" ; default only for mail/post folders
            If $oFolder.DefaultMessageClass = "IPM.NOTE" Then Return SetError(3, 0, 0)
        Case Else ; New message class has to start with the DefaultMessageClass e.g. IPM.NOTE.mynote for class IPM.NOTE
            If StringInStr($sMsgClass, $oFolder.DefaultMessageClass) <> 1 Then Return SetError(4, 0, 0)
    EndSwitch
    $iLoc = StringInStr($sMsgClass, ".", 0, -1) ; Find last "." in class
    If @error Then Return SetError(5, 0, 0)
    Local $aSchema[2] = [$PR_DEF_POST_MSGCLASS, $PR_DEF_POST_DISPLAYNAME]
    Local $aValues[2] = [$sMsgClass, StringMid($sMsgClass, $iLoc + 1)]
    $oPropertyAccessor = $oFolder.PropertyAccessor
    $oPropertyAccessor.SetProperties($aSchema, $aValues)
    If @error Then Return SetError(6, @error, 0)
    $oPropertyAccessor = 0
EndFunc   ;==>_OL_FolderClassSet

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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...