willsonfang Posted September 8, 2011 Share Posted September 8, 2011 (edited) Hi, First time posting on this forum, just found AutoIt about couple days ago. I've manage to automate about 10% of my current work, and looking to go further with AutoIt, but have hit a brick wall. Basically what I'm trying to do is, get AutoIt to run a Outlook macro I have designed. The general gist of the macro is it saves all attachments from a specific outlook folder, with a date frame and a extension limit to a specified explorer folder. If there is a more convenient method to do this in AutoIt, I'm up for suggestions (but since the Macro has already been created in Outlook, it should just be easier to call the macro) I have already seen examples of Excel macros being called, and have tried it myself, but unsure how to replicate it for Outlook. Regards, Phoenix Edited September 8, 2011 by willsonfang Link to comment Share on other sites More sharing options...
Juvigy Posted September 8, 2011 Share Posted September 8, 2011 I think MS doesnt support this in versions later than O2000 for seciruty reasons. You can however convert the macro code to Autoit. Link to comment Share on other sites More sharing options...
water Posted September 8, 2011 Share Posted September 8, 2011 If you want to convert it to AutoIt please have a look at my OutlookEX UDF. With function _OL_ItemFind you can limit the number of items to process. With _OL_ItemSave you can save the attachments. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
willsonfang Posted September 9, 2011 Author Share Posted September 9, 2011 (edited) If you want to convert it to AutoIt please have a look at my OutlookEX UDF.With function _OL_ItemFind you can limit the number of items to process. With _OL_ItemSave you can save the attachments. So is a conditional ItemSave possible:Find all Unread emails in a specified folder (hard-coded folder)Filter all emails based on todays dateFilter all emails based on if they have a attachment or notFilter all emails based on a whitelist of extentions (4 extensions currently)Dump attachments to a specified folder with todays date as nameThat is what my current macro does (found the base of it online, just did small modifications to add extra functionality) I think MS doesnt support this in versions later than O2000 for seciruty reasons. You can however convert the macro code to Autoit. Then I would assume, if I use sendkeys and mouse click macros, that is the only way to run the macro? Edited September 9, 2011 by willsonfang Link to comment Share on other sites More sharing options...
water Posted September 9, 2011 Share Posted September 9, 2011 So is a conditional ItemSave possible:Find all Unread emails in a specified folder (hard-coded folder)Filter all emails based on todays dateFilter all emails based on if they have a attachment or notFilter all emails based on a whitelist of extentions (4 extensions currently)Dump attachments to a specified folder with todays date as nameThat is what my current macro does (found the base of it online, just did small modifications to add extra functionality) Yes. I will post an example as soon as I return to my office. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Juvigy Posted September 9, 2011 Share Posted September 9, 2011 You can opt. to use send keys but i would advise you not to. Just post here the macro code - i think it will be easy to convert it to AIT. There is part of the task already done somewhere in the forums. Link to comment Share on other sites More sharing options...
water Posted September 11, 2011 Share Posted September 11, 2011 (edited) So is a conditional ItemSave possible:Find all Unread emails in a specified folder (hard-coded folder)Filter all emails based on todays dateFilter all emails based on if they have a attachment or notFilter all emails based on a whitelist of extentions (4 extensions currently)Dump attachments to a specified folder with todays date as nameAn AutoIt script to do what you need could look like (testing needed!):$oOL = _OL_Open() $aFolder = _OL_FolderAccess($oOL, "", $olFolderInbox) ; Access the users inbox $aItems = _OL_ItemFind($oOL, $aFolder[1], $olMail, "[UnRead]=True And [ReceivedTime]>='12/09/2011 00:00' And [ReceivedTime]<='12/09/2011 23:59'", "", "", "Subject,Body,Attachments,EntryID") ; Find all unread items received today For $i = 1 to $aItems[0][0] ; Check all found items If IsObj($aItems[$i][2]) and $aItems[$i][2].Count > 0 Then ; Does the item have an attachment object and is the number of attachments > 0? $aAttachments = _OL_ItemAtttachementGet($ol, $aItems[$i][3]) For $j = 1 to $aAttachments[0][0] ; This part needs some brush up!! If $aAttachments[$j][2] = "xxxx.yyy" Then _OL_ItemSave($oOL, $aItems[$i][3], Default, "C:\temp\", $olTXT, 2) Next EndIf Next _OL_Close($oOL) Do your mails have either only one attachement or do you always want to save all attachments of a mail? At the moment I can save an item plus ALL attachments only. Edited September 12, 2011 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now