Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

  • Replies 634
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console. Use _OL_ItemAttachmentSave to save the attachment

The list of profiles is stored in the registry:"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook" or "HKEY_CURRENT_USER\Software\Microsoft\Wi

So the key "Default" doesn't apply to any default signature? This would be a difficult for multi-user because everyone signature might be different. I would assume there is a function just to use a

Posted Images

What would you do with the information that the PST is password protected? As you can't enter the password by your script the user always has to enter it himself.

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 2 weeks later...

The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console.

Use _OL_ItemAttachmentSave to save the attachments of your mails.

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>
Global $aAttachments

; Connect to Outlook
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; Access the Inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended)

; Search for unread items with attachments
Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0"
Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject")
If @error Then
    MsgBox(16, "OutlookEX UDF - _OL_ItemSearch Example Script", "Error running _OL_ItemSearch. @error = " & @error & ", @extended = " & @extended)
Else
    _Arraydisplay($aResult, "Example 6")
EndIf

; Now get a list of attachments
For $i = 1 To $aResult[0][0]
    ConsoleWrite($aResult[$i][1] & @CRLF) ; Mail subject
    $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0])
    For $j = 1 To $aAttachments[0][0]
        ConsoleWrite("  " & $aAttachments[$j][2] & @CRLF) ; Name of atachment
    Next
Next

_OL_Close($oOutlook)
Exit

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Water,

Do you have any Plans to add option to allow us to compact a PST file ?

I've created a Autoit process using your UDF that moves items around, deletes them etc.

I have found that Outlook does not seem to compact on a reliable basis , for example aftter

moving 4000 items to the deleted folder and purging them, and waited 5 days , the Outlook Compact never ran.

I ran it manually on the 5th day and it took the size of the PST folder from 2.9 Gig, down to 200 MB.

Please let me know if this is something you are considering ?

Thanks

Paul

Edited by HighlanderSword
Link to post
Share on other sites

I have considered to add a PST compact function. Unfortunately Outlook doesn't offer a method in the object model. So, no, there will be no such function in the OutlookEX UDF.

The only way to do it by script is to automate the Outlook GUI.

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Thank you Water - You make it seem so easy. I have a question. Is it possible not to include people big signature in my attachment? and I only want it to save the pdf file not all the jpg gif that come with the email?

The following example gets all unread items with at least one attachment and writes the mail subject plus the name of all attachments to the Console.

Use _OL_ItemAttachmentSave to save the attachments of your mails.

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>
Global $aAttachments

; Connect to Outlook
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; Access the Inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended)

; Search for unread items with attachments
Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0"
Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject")
If @error Then
MsgBox(16, "OutlookEX UDF - _OL_ItemSearch Example Script", "Error running _OL_ItemSearch. @error = " & @error & ", @extended = " & @extended)
Else
_Arraydisplay($aResult, "Example 6")
EndIf

; Now get a list of attachments
For $i = 1 To $aResult[0][0]
ConsoleWrite($aResult[$i][1] & @CRLF) ; Mail subject
$aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0])
For $j = 1 To $aAttachments[0][0]
ConsoleWrite(" " & $aAttachments[$j][2] & @CRLF) ; Name of atachment
Next
Next

_OL_Close($oOutlook)
Exit

Link to post
Share on other sites

Water,

Thanks for the assist and I couldn't reply thanks to PM.

Mine seems to be over complicated.

#include <OutLookEX.au3>

Global $aItems, $Result
Global $oOutlook = _OL_Open()
Global $oOApp = ObjCreate("Outlook.Application")
Global $aFolder = _OL_FolderAccess($oOutlook, "*Inbox", Default, Default)
Global $sFilter = "@SQL=(""urn:schemas:httpmail:hasattachment"" = 1 AND ""urn:schemas:httpmail:read"" = 0)"
$aItems = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID")

;~ $aItems = _OL_ItemFind($oOutlook, $vOlFolder, $olMail, "[UnRead]=True", "", "", "EntryID", "")
If IsArray($aItems) Then
For $i = 1 To $aItems[0][0]
$Result = _OL_ItemAttachmentGet($oOutlook, $aItems[$i][0], Default)
    ;mark as read first to prevent read receipt confusion massacre
    _OL_ItemModify($oOutlook, $aItems[$i][0], Default, "UnRead=False")

    Global $oOL_Item = $oOApp.Session.GetItemFromID($aItems[$i][0], Default)
    Global $var = $oOL_Item.Subject
If IsArray($Result) Then
    For $r = 1 To $Result[0][0]
        _OL_ItemAttachmentSave($oOutlook, $aItems[$i][0], Default, 1, "c:outlook" & $var & "" & $Result[$r][1])

    Next
Else
;YAY!
EndIf
Next
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf
Link to post
Share on other sites

@Mun,

use _OL_ItemAttachmentGet to get a list of all attachments of a mail item. You then can decide which one to save using _OL_ItemAttachmentSave.What do you mean by : "not to include people big signature in my attachment"?

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

@Crayfish,

Why do you use

Global $oOApp = ObjCreate("Outlook.Application")
That's exactly what is returned by _OL_Open.

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

It saved people signature images as additional attachment. I will read up and on what you suggested thanks Water

@Mun,

use _OL_ItemAttachmentGet to get a list of all attachments of a mail item. You then can decide which one to save using _OL_ItemAttachmentSave.What do you mean by : "not to include people big signature in my attachment"?

Link to post
Share on other sites

Water, I read up on it. I still can't able to filter out those signature gif/jpg not to include in the folder. Is there a way?

Could you check up on the following code to see if it's done correctly?

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

Global $aAttachments
Global $oOutlook = _OL_Open()
Global $SaveLOC = @ScriptDir & "\MSG_TEST\"
; Access the Inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "*\Inbox", $olFolderInbox)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the Inbox. @error = " & @error & ", @extended = " & @extended)

;Search for unread items with attachments
Global $sFilter = "@SQL=""urn:schemas:httpmail:hasattachment"" = 1 and ""urn:schemas:httpmail:read""=0"
Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,Subject")

For $Email = 1 To $aResult[0][0]
    $aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$Email][0])
    ConsoleWrite($aResult[$Email][1] & " Attachments: " & $aAttachments[0][0] & @CRLF)
    For $AIndex = 1 To $aAttachments[0][0]
        _OL_ItemAttachmentSave($oOutlook, $aResult[$Email][0], Default, $AIndex, $SaveLOC & $aResult[$Email][1] & "\" & $aAttachments[$AIndex][2])
        If @error <> 0 Then MsgBox(16, "Error", "Error saving attachments to folder. @error = " & @error & ", @extended = " & @extended)
        sleep(200)
    Next
Next

; Close connection to Outlook
_OL_Close($oOutlook)
Link to post
Share on other sites

If the signature of a user contains an attachment then it's an attachment like any other attachment to the recipient. The signature is a part of the message. If you can't distinguish by name, filetype or whatever then you are out of luck.

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
  • 2 weeks later...

As the OutlookEX UDF - Help & Support thread has grown too big, I started a new one.

The new thread can be found

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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...