Jump to content

Run Outlook Macro


Recommended Posts

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 by willsonfang
Link to comment
Share on other sites

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

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 date
  • Filter all emails based on if they have a attachment or not
  • Filter all emails based on a whitelist of extentions (4 extensions currently)
  • Dump attachments to a specified folder with todays date as name
That 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 by willsonfang
Link to comment
Share on other sites

So is a conditional ItemSave possible:

  • Find all Unread emails in a specified folder (hard-coded folder)
  • Filter all emails based on todays date
  • Filter all emails based on if they have a attachment or not
  • Filter all emails based on a whitelist of extentions (4 extensions currently)
  • Dump attachments to a specified folder with todays date as name
That 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 - 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

So is a conditional ItemSave possible:

  • Find all Unread emails in a specified folder (hard-coded folder)
  • Filter all emails based on todays date
  • Filter all emails based on if they have a attachment or not
  • Filter all emails based on a whitelist of extentions (4 extensions currently)
  • Dump attachments to a specified folder with todays date as name
An 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 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...