Jump to content

OutlookEX UDF - Help & Support


Recommended Posts

You are welcome ;)

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

water

Hoping you can help with an Attachment Save problem i have.

I have the following code which checks for the type of attachment and if it is not a PDF it processes an action, either deleting the attachment or saving it.

I'm using _OL_ItemAttachmentSave, but there may be attachments with the same name, so I tried to use _OL_ItemSave, but I can't figure out where in my code _OL_ItemSave should go.

Global $sFilter = "@SQL=(""urn:schemas:httpmail:hasattachment"" = 1 AND ""urn:schemas-microsoft-com:office:office#Keywords"" = 'AutoIT')"
Global $aResult = _OL_ItemSearch($oOutlook, $aFolder[1], $sFilter, "EntryID,subject")
If @error Then
    MsgBox(16, "Searching", "Error Searching Marketplace InvoicesInbox for emails with attachments and the 'AutoIT' category. @error = " & @error & ", @extended = " & @extended)
    Exit
Else
    traytip("Searching", "Searching for non-PDF attachments and marking them with the 'Non-PDF' category", 30, 1)
    Sleep(2000)
EndIf

; Get a list of attachments and save non-PDF attachments for changing to PDFs
For $i = 1 To $aResult[0][0]
ConsoleWrite($aResult[$i][1] & @CRLF)
$aAttachments = _OL_ItemAttachmentGet($oOutlook, $aResult[$i][0])
For $j = 1 To $aAttachments[0][0]
  If StringRegExp($aAttachments[$j][2], "pdf$|PDF$") Then
   ConsoleWrite("  " & $aAttachments[$j][2] & @CRLF)
  ElseIf StringRegExp($aAttachments[$j][2], "mht$|txt$|png$") Then
   _OL_ItemAttachmentDelete($oOutlook, $aResult[$i][0], Default, $aAttachments[0][0])
   If @error <> 0 Then MsgBox(16, "Error", "Error deleting attachments from email. @error = " & @error & ", @extended = " & @extended)
  Else
   _OL_ItemAttachmentSave($oOutlook, $aResult[$i][0], Default, $aAttachments[0][0], $SavePath & "" & $aAttachments[$j][2])
   ;_OL_ItemSave($oOutlook, $aResult[$i][0], Default, $SavePath & "", $olHTML, 2)
   If @error <> 0 Then MsgBox(16, "Error", "Error saving attachments to PDFConversionArea folder. @error = " & @error & ", @extended = " & @extended)
   ;Set 'Non-PDF' category
   _OL_ItemModify($oOutlook, $aResult[$i][0], Default, "Categories=Non-PDF", "UnRead=False" )
   If @error <> 0 Then Exit MsgBox(16, "Update Category", "Error marking item with 'Non-PDF' category. @error = " & @error & ", @extended = " & @extended)
  EndIf
Next
Next

To be clear the attachment should only be saved if it is not a PDF.

Link to comment
Share on other sites

Change line

_OL_ItemAttachmentSave($oOutlook, $aResult[$i][0], Default, $aAttachments[0][0], $SavePath & "" & $aAttachments[$j][2])
to
_OL_ItemAttachmentSave($oOutlook, $aResult[$i][0], Default, $j, $SavePath & "" & $aAttachments[$j][2])
You specified the total number of attachments in the mail but you need to specify the index of the attachment to save.

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

Thanks water

Another problem I have come across when using _OL_ItemAttachmentSave is an attachment with the same name, but attached to a separate email e.g. Email 1 with attachment named 'attachment1.pdf' and Email 2 with attachment named 'attachment1.pdf'.

Do you have any idea how I can get round this, as at the moment I get error code 4 when using _OL_ItemAttachmentSave.

Many thanks in advance.

Link to comment
Share on other sites

HI Water

I'm trying to write a little script to Email customers from my Outlook Contacts.

Basic steps

Querry contacts - Customers that I haven't seen for 12 months

Send an Email.

Add to the NOTES field that an email was sent

But I've hit a snag at the first step.

I can't work out how to query with a range of dates.

I think it should be something liek this.

Local $sStartDate = "???????" ' Start of range to extract
Local $sEndtDate = "???????" ' End of range to extract
Local $aItems = _OL_ItemFind($oOutlook, $oOL_ContactFolder, $olContact, _
   '[JobTitle] = "Customer" and [Anniversary] > "' & $sStartDate & '" and [Anniversary] < "' & $sEndDate & '"', "", "", _
   "EntryID,FullName,CompanyName,Anniversary,Email2Address,Email1Address,Email3Address", "", 1)

I'm not sure what format the "$sStartDate" and "$sEndtDate" should be and should the dates be enclosed in inverted commas in the query.

Any help would be appreciated! Thanks

John Morrison

Edit: answered a stupid question myself so I deleted it to cover it up. ;)

Edited by storme
Link to comment
Share on other sites

Another problem I have come across when using _OL_ItemAttachmentSave is an attachment with the same name, but attached to a separate email e.g. Email 1 with attachment named 'attachment1.pdf' and Email 2 with attachment named 'attachment1.pdf'.

You could do a
FileExists($SavePath & "" & $aAttachments[$j][2])
before calling _OL_ItemAttachmentSave. If the file already exists pass another path/filename as parameter $sOL_Path. 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

Not sure if anyone has posed this.

http://www.microeye.com/resources/ObjectModel.htm

it's a VERY LARGE PDF/Visio diagram that contains all the objects in outlook and how they interconnect.

It's great for a birds-eye-view and how everything intereconnects.

Hope it helps someone.

John Morrison

Link to comment
Share on other sites

I found this great diagram when I started to search for info on the Outlook COM Model. MS has something similar but - as it is written by MS - it is completely useless.

The object model you posted is for Outlook 2000.

Here is the Outlook 2003 version.

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

When searching for mails I use the following format:

Local $sStartDate = "2011-02-21 08:00"
Local $sEndtDate = "2012-02-21 08:00"

Example can be found here.

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 found this great diagram when I started to search for info on the Outlook COM Model. MS has something similar but - as it is written by MS - it is completely useless.

The object model you posted is for Outlook 2000.

Here is the Outlook 2003 version.

Thanks! those files are so big I didn't notice what version it was...DOH! ;)

Link to comment
Share on other sites

When searching for mails I use the following format:

Local $sStartDate = "2011-02-21 08:00"
Local $sEndtDate = "2012-02-21 08:00"

Example can be found here.

DAM! Sorry about that I have ALL the HELP files here and looked at that one and just plain didn't see that.

So a second SORRY for the day!!! ;)

Edited by storme
Link to comment
Share on other sites

No problem ;)

I myself get lost sometimes in the piles of code and documentation I write ...

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

When searching for mails I use the following format:

Local $sStartDate = "2011-02-21 08:00"
Local $sEndtDate = "2012-02-21 08:00"

Example can be found here.

I tried that and I can't get it to work. :)

After the Range didn't work I decided to try and extract just one item.

The Customer has an Anniversary field = "20120524000000" 2012-05-24

This is the code I came up with.

Local $sStartDate = "2012-05-24 00:00" ; Start of range to extract
 ;Local $sEndtDate = "2011-05-30 00:00" ; End of range to extract
 Local $aItems = _OL_ItemFind($oOutlook, $oOL_ContactFolder, $olContact _
   ,'[JobTitle] = "Customer" And [Anniversary] = "' & $sStartDate & '"' _
   , "", "" _
   ,"EntryID,FullName,CompanyName,Anniversary,Email2Address,Email1Address,Email3Address", "", 1)
 If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemModify Example Script", "Error modifying a contact in folder 'Outlook-UDF-TestSourceFolderContacts'. @error = " & @error)
 _ArrayDisplay($aItems)

I also tried (used the > and made the date one day less

Local $sStartDate = "2012-05-23 00:00" ; Start of range to extract
 ;Local $sEndtDate = "2011-05-30 00:00" ; End of range to extract
 Local $aItems = _OL_ItemFind($oOutlook, $oOL_ContactFolder, $olContact _
   ,'[JobTitle] = "Customer" And [Anniversary] > "' & $sStartDate & '"' _
   , "", "" _
   ,"EntryID,FullName,CompanyName,Anniversary,Email2Address,Email1Address,Email3Address", "", 1)
 If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemModify Example Script", "Error modifying a contact in folder 'Outlook-UDF-TestSourceFolderContacts'. @error = " & @error)
 _ArrayDisplay($aItems)

I even tried (amoungst other things)

Local $sStartDate = "20120524000000" ; Start of range to extract
 ;Local $sEndtDate = "2011-05-30 00:00" ; End of range to extract
 Local $aItems = _OL_ItemFind($oOutlook, $oOL_ContactFolder, $olContact _
   ,'[JobTitle] = "Customer" And [Anniversary] = "' & $sStartDate & '"' _
   , "", "" _
   ,"EntryID,FullName,CompanyName,Anniversary,Email2Address,Email1Address,Email3Address", "", 1)
 If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemModify Example Script", "Error modifying a contact in folder 'Outlook-UDF-TestSourceFolderContacts'. @error = " & @error)
 _ArrayDisplay($aItems)

and still got nothing.

I can just extract the whole data then crawl thorugh the array. However, it woudl be much more elegant if I could get Outlook to do ti for me. ;)

I've got to be missing something but I just don't know what.

BTW if I remove the "Anniversary" condition I get an array containing all the customers....sigh

Link to comment
Share on other sites

I tried here (German Outlook 2010) and the following selections work:

$sStartDate = "2012-05-30"
$sStartDate = "30.5.2012"
$sStartDate = "30.05.2012"
$sStartDate = "31 May, 2012"
$sStartDate ="05/30/2012" ; MMDDYYYY depending on the locale
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

A good reading is this article.

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 tried here (German Outlook 2010) and the following selections work:

$sStartDate = "2012-05-30"
$sStartDate = "30.5.2012"
$sStartDate = "30.05.2012"
$sStartDate = "31 May, 2012"

AHHHH so it was the TIME that didn't need to be there!

Makes sense but as you stated earlier you use the time (eg "2011-02-21 08:00") when searching for Emails so I assumed that it would be consistant.

Sigh....

Thanks for working that out for me!!!

Link to comment
Share on other sites

I hate the different formats for dates you can use in MS Office products plus the locale dependant variations.

www.outlookcode.com describes quite good how it is supposed to work ;)

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

Is it posible to get out all Mapi Profile's?

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\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" depending on the Outlook version.

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