Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

Would function _OL_ItemAttachmentGet do what you need? It lists all attachments and returns a 2D array. In element 6 you find the type of the attachment as described here.

I assume a true attachment has the type of 1.

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 have added both properties to the _OL_ItemAttachmentGet function. Does this return the values you are looking for?

Func _OL_ItemAttachmentGet($oOL, $vOL_Item, $sOL_StoreID = Default)

    Local $PR_ATTACH_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x37140003"
    Local $PR_ATTACHMENT_HIDDEN = "http://schemas.microsoft.com/mapi/proptag/0x7FFE000B"
    If Not IsObj($vOL_Item) Then
        If StringStripWS($vOL_Item, 3) = "" Then Return SetError(1, 0, 0)
        $vOL_Item = $oOL.Session.GetItemFromID($vOL_Item, $sOL_StoreID)
        If @error Then Return SetError(2, @error, 0)
    EndIf
    If $vOL_Item.Attachments.Count = 0 Then Return SetError(3, 0, 0)
    Local $aOL_Attachments[$vOL_Item.Attachments.Count + 1][9] = [[$vOL_Item.Attachments.Count, 9]]
    Local $iOL_Index = 1
    For $oOL_Attachment In $vOL_Item.Attachments
        $aOL_Attachments[$iOL_Index][0] = $oOL_Attachment
        $aOL_Attachments[$iOL_Index][1] = $oOL_Attachment.DisplayName
        $aOL_Attachments[$iOL_Index][2] = $oOL_Attachment.FileName
        $aOL_Attachments[$iOL_Index][3] = $oOL_Attachment.PathName
        $aOL_Attachments[$iOL_Index][4] = $oOL_Attachment.Position
        $aOL_Attachments[$iOL_Index][5] = $oOL_Attachment.Size
        $aOL_Attachments[$iOL_Index][6] = $oOL_Attachment.Type
        $aOL_Attachments[$iOL_Index][7] = $oOL_Attachment.PropertyAccessor.GetProperty($PR_ATTACH_FLAGS)
        $aOL_Attachments[$iOL_Index][8] = $oOL_Attachment.PropertyAccessor.GetProperty($PR_ATTACHMENT_HIDDEN)
        $iOL_Index += 1
    Next
    Return $aOL_Attachments

EndFunc   ;==>_OL_ItemAttachmentGet

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

Water,

What is the best way to count how many attached images (live) on the new mail?

I am using a DTE software that use outlook 2007 to send mail with attached images. Can OutlookEX UDF catch and see how many images attached in the email before DTE send out?

You don't have to do the work script etc.

I am willing to learn. Just point me the right way and kick me down the path.

Link to comment
Share on other sites

The only possible way I can think of is to use events. For MailItems there is the Send event which is called before the item is sent.

You can set the cancel flag so the send operation is not completed.

Haven't done it myself (yet). I'm not sure how to grab the send event for a mail another program raises.

Will do some testing ...

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

@mdcastle,

I have added both properties to the _OL_ItemAttachmentGet function. Does this return the values you are looking for?

I have been thinking about this two properties and if I should add them to the regular UDF function. As this is a very special information not used by everybody and on the other hand only one of many other properties for an attachment item I think it will not make it into the next release.

As I return the item object in the array you can easily access the needed properties after you've called function _OL_ItemAttachmentGet.

Is this ok for you?

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

The only possible way I can think of is to use events. For MailItems there is the Send event which is called before the item is sent.

You can set the cancel flag so the send operation is not completed.

Haven't done it myself (yet). I'm not sure how to grab the send event for a mail another program raises.

Will do some testing ...

Water,

DTE doesn't actually send the email. It will create a new mail with attached images (sometime 4 photos sometime 20 photos, etc) The users normally count how many attached photos and type in the body: i.e. Here are 4 photos you requested. Here are 20 photos you requested, etc.

(Outlook give you 2 lines to preview with tiny scrollbar, sometime it hard to count 60+ photos and I keep miscount numbers of photos)

That the reason why I was wonder if OutlookEX can count how many attached photos from a new mail for more accurate reason.

MailItems cancel flag would not needed because the mail hasn't been send until I hit the send button.

All DTE does it create a new mail and attached the images base on the specific request and leave the mail open for me to review.

Link to comment
Share on other sites

So the mail is located in the "Drafts" folder? Then it would be easy to grab the MailItem and count the number of photos.

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

Heya, thanx for this great UDF.

My goal is to search the GAL (Global address list) and retrieve a telephone number of a contact.

So far i've managed to retrieve the entire list by using _OL_AddressListMemberGet

#include <outlookex.au3>
#include <array.au3>
Opt("MustDeclareVars", 0)

$oOL = _OL_Open()
$ListArray = _OL_AddressListGet($oOL)
$GalMembers = _OL_AddressListMemberGet($oOL, $ListArray[3][1])
_ArrayDisplay($GalMembers)

However, the array created by this function doesn't seem to contain the telephone field.

I've search this thread and it seems i'm suposed to use the _OL_ItemFind in order to achieve my goal? If so, the syntax makes me very frustrated, specificly the $vOL_Folder-variable (return from _OL_FolderAccess). How do know what folder the GAL is in? Is there a way to list the Outlook folders somehow?

Help on this matter would be much appreciated.

Edited by faldo
Link to comment
Share on other sites

To check which of the address lists is the GAL you can run _OL_AddressListGet and check for the entry which has a value of 0 in column zero. Thats the value of the OlAddressListType enumeration for the GAL.

But if it is an Exchange based address list you can't access it like a folder.

I will check how to search only in the GAL ...

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

To check which of the address lists is the GAL you can run _OL_AddressListGet and check for the entry which has a value of 0 in column zero. Thats the value of the OlAddressListType enumeration for the GAL.

But if it is an Exchange based address list you can't access it like a folder.

I will check how to search only in the GAL ...

Thanx for a quick respone. I don't specificly require a search function, if i can retieve an array with the entire global addresslist, much line the _OL_AddressListMemberGet-function but with telephone number as a column, it'll do just fine.

I tried to alter the _OL_AddressListMemberGet-function at

$aOL_Members[$iOL_Index][1] = $oOL_Item.Name

and changed it to

$aOL_Members[$iOL_Index][1] = $oOL_Item.Telephone

But that didn't work, heh.

Edited by faldo
Link to comment
Share on other sites

$oOL_Item at this time is only an address entry without the required property.

Depending on the address entry type you have to access the user or contact details.

There isn't a single "Telephone" property in the address entry but multiple named HomeTelephoneNumber, CompanyMainTelephoneNumber etc.

So first you have to decide which property you need. Then access the property:

; Exchange user that belongs to the same or a different Exchange forest
If $oOL_Item.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Item.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then
$aOL_Members[$iOL_Index][4] = $oOL_Item.GetExchangeUser
     ConsoleWrite($aOL_Members[$iOL_Index][4].<Propertyname> & @CRLF)
EndIf
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

@mdcastle,

I have been thinking about this two properties and if I should add them to the regular UDF function. As this is a very special information not used by everybody and on the other hand only one of many other properties for an attachment item I think it will not make it into the next release.

As I return the item object in the array you can easily access the needed properties after you've called function _OL_ItemAttachmentGet.

Is this ok for you?

Absolutely fine. Thanks for showing me the required code.

Link to comment
Share on other sites

Glad to be of service :D

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

$oOL_Item at this time is only an address entry without the required property.

Depending on the address entry type you have to access the user or contact details.

There isn't a single "Telephone" property in the address entry but multiple named HomeTelephoneNumber, CompanyMainTelephoneNumber etc.

So first you have to decide which property you need. Then access the property:

; Exchange user that belongs to the same or a different Exchange forest
If $oOL_Item.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Item.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then
$aOL_Members[$iOL_Index][4] = $oOL_Item.GetExchangeUser
     ConsoleWrite($aOL_Members[$iOL_Index][4].<Propertyname> & @CRLF)
EndIf

Thanx a bunch!

With your permission, i added a Mobile Phone-column to your _OL_AddressListMemberGet-function:

Func _OL_AddressListMemberGet($oOL, $vOL_ID)
If StringStripWS($vOL_ID, 3) = "" Then Return SetError(1, 0, "")
Local $oOL_Items = $oOL.Session.AddressLists.Item($vOL_ID).AddressEntries
If @error Then Return SetError(2, @error, 0)
Local $aOL_Members[$oOL_Items.Count + 1][5] = [[$oOL_Items.Count, 5]], $iOL_Index = 1
For $oOL_Item In $oOL_Items
$aOL_Members[$iOL_Index][0] = $oOL_Item.Address ; <== ??
$aOL_Members[$iOL_Index][1] = $oOL_Item.Name
$aOL_Members[$iOL_Index][2] = $oOL_Item.AddressEntryUserType
$aOL_Members[$iOL_Index][3] = $oOL_Item.ID

; Exchange user that belongs to the same or a different Exchange forest
If $oOL_Item.AddressEntryUserType = $olExchangeUserAddressEntry Or $oOL_Item.AddressEntryUserType = $olExchangeRemoteUserAddressEntry Then
$aOL_Members[$iOL_Index][4] = $oOL_Item.GetExchangeUser
$aOL_Members[$iOL_Index][0] = $aOL_Members[$iOL_Index][4] .PrimarySmtpAddress
$aOL_Members[$iOL_Index][4] = $aOL_Members[$iOL_Index][4] .MobileTelephoneNumber
EndIf
; Address entry in an Outlook Contacts folder
If $oOL_Item.AddressEntryUserType = $olOutlookContactAddressEntry Then
$aOL_Members[$iOL_Index][4] = $oOL_Item.GetContact
$aOL_Members[$iOL_Index][0] = $aOL_Members[$iOL_Index][4] .Email1Address
$aOL_Members[$iOL_Index][4] = $aOL_Members[$iOL_Index][4] .MobileTelephoneNumber
EndIf

$iOL_Index += 1
Next
Return $aOL_Members
EndFunc ;==>_OL_AddressListMemberGet
Link to comment
Share on other sites

You don't need to change the function. As the object is returned in element $aOL_Members[$iOL_Index][4] you can easily access the property using the returned array.

$aResult = _OL_AddressListMemberGet($oOL, 1)
For $i = 1 to $aResult[0][0]
    ConsoleWrite($aResult[$i][4].MobileTelephoneNumber & @CRLF)
Next

This way your scripts don't crash when a new version of the UDF is released.

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

You don't need to change the function. As the object is returned in element $aOL_Members[$iOL_Index][4] you can easily access the property using the returned array.

$aResult = _OL_AddressListMemberGet($oOL, 1)
For $i = 1 to $aResult[0][0]
ConsoleWrite($aResult[$i][4].MobileTelephoneNumber & @CRLF)
Next

This way your scripts don't crash when a new version of the UDF is released.

Even better :)

Cheers

Link to comment
Share on other sites

:D

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 hoping you can help me, again!

I have the following code that loops through and deletes attachments:

For $i = 1 To $aResult[0][0]
$aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0])
For $j = 1 To $aAttachments[0][0]
If $aAttachments[$j][7] = "4" AND $aAttachments[$j][8] = "True" Then
_OL_ItemAttachmentDelete($oOutlook, $aResult[$i][0], Default, $j)
If @error <> 0 Then MsgBox(16, "Error", "Error deleting the attachment. @error = " & @error & ", @extended = " & @extended)
EndIf
Next
Next

The problem is I need to refresh the list of attachments each time one is deleted as the attachment number changes after each attachment is deleted. I'm sure its easy but I've got a mental block :(

Many thanks in advance.

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...