water Posted May 23, 2012 Author Posted May 23, 2012 You are welcome 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
mdcastle Posted May 29, 2012 Posted May 29, 2012 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.
water Posted May 29, 2012 Author Posted May 29, 2012 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 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
mdcastle Posted May 30, 2012 Posted May 30, 2012 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.
storme Posted May 30, 2012 Posted May 30, 2012 (edited) 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 May 30, 2012 by storme Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
water Posted May 30, 2012 Author Posted May 30, 2012 (edited) 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 May 30, 2012 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
storme Posted May 30, 2012 Posted May 30, 2012 Not sure if anyone has posed this.http://www.microeye.com/resources/ObjectModel.htmit'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 Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
water Posted May 30, 2012 Author Posted May 30, 2012 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 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
water Posted May 30, 2012 Author Posted May 30, 2012 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 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
storme Posted May 30, 2012 Posted May 30, 2012 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! Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
storme Posted May 30, 2012 Posted May 30, 2012 (edited) 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 May 30, 2012 by storme Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
water Posted May 30, 2012 Author Posted May 30, 2012 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 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
storme Posted May 30, 2012 Posted May 30, 2012 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 Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
water Posted May 30, 2012 Author Posted May 30, 2012 (edited) 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 May 30, 2012 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
water Posted May 30, 2012 Author Posted May 30, 2012 A good reading is this article. 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
storme Posted May 30, 2012 Posted May 30, 2012 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!!! Some of my small contributions to AutoIt Browse for Folder Dialog - Automation SysTreeView32 | FileHippo Download and/or retrieve program information | Get installedpath from uninstall key in registry | RoboCopy function John Morrison aka Storm-E
water Posted May 30, 2012 Author Posted May 30, 2012 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 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
water Posted May 31, 2012 Author Posted May 31, 2012 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. Spenhouet 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
Spenhouet Posted May 31, 2012 Posted May 31, 2012 Thx this works fine Is it possible to create a new mapi outlook profile? how?
Recommended Posts