Jump to content

OutlookEX UDF: Example scripts


water
 Share

Recommended Posts

Version 1.2.0.0 of the UDF has been released.

Please test before using in production!

For download please see my signature.

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

  • 2 months later...

Water,

 

Is there a way with your UDF to create a mail or .eml file on disk that can be stored until I am ready to send it.  I would like to have everything filled in as much as possible such as attachments and email body with the sender emails already pre populated.  I will them be putting a feature in my program to simply send the files that are on disk in a big batch at a specific time.

 

Many Thanks

 

Link to comment
Share on other sites

I would use _OL_ItemSave to save the mail to disk and then use _OL_ItemCreate and use the saved file as template and then send the item using _OL_ItemSend.

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.  What if the mail item did not exist as I am trying to create them on the fly with some dynamic content form a database .  What I am doing is creating a load of emails with different content which will be emailed to the contacts list in my database.  Would i just need to do an _ol_itemSave for an example email i have created then just keep re-using this.  I will have a play with these suggestions.

 

Thanks for your assistance.

 

Link to comment
Share on other sites

You could create a template with tags to replace with variable data from your database (like: %name% etc.)

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 will try that.  Is there a way still to save the email to disk just before sending it.  i am looking to gain some confidence the email is correct and looks good before sending it.  Once I am happy it is behaving I will enable the auto send feature.  

Thanks

 

Link to comment
Share on other sites

Why do you need to save the mail to disk? Couldn't you store the mails in Outlook until you decide to send them?

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

That is an option.   I will look into how I do this without sending the actual email.  I guess this will be the same as before but without actually executing the email send bit and will be stored as a draft email.

 

 

Link to comment
Share on other sites

Correct.

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

  • 3 months later...

Hello water,

I joined this forum specifically to write this post.  I just want to say Thank You for your OutlookEX and your _OL_Example_NewMail_Event.au3 example script.  I've never written an AutoIt script before, but I managed to add two lines to your example and make something that I've wanted for years, namely, light up an LED when an email arrives.  I bought something called the blink(1) LED <https://blink1.thingm.com> and used your script to launch its command line tool, blink1-tool, and it just worked!  Now, every time a new email arrives, the blink(1) lights up and your message box pops up.  The blink(1) goes out when I close the message box.  Perfect!

Here's the modified version of your oOApp_NewMailEx() function:

Func oOApp_NewMailEx($sOL_EntryId)

    Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default)
    Run('"c:\Users\<user>\Downloads\Blink(1)\blink1-tool.exe" --rgb 255,153,0')
    MsgBox(64, "OutlookEX UDF Example Script", "Rob's New mail has arrived!" & @CRLF & @CRLF & _
            "From:    " & $oOL_Item.SenderName & @CRLF & _
            "Subject: " & $oOL_Item.Subject)
   
    Run('"c:\Users\<user>\Downloads\Blink(1)\blink1-tool.exe" --off')

Note that I just added the two 'Run' lines that sandwich your MsgBox call.  The first 'Run' turns on the LED to a bright orange color and the second 'Run' turns it off.  It was as simple as that.

I'm in no way affiliated with the blink(1) people, I just wanted to say how thrilled I am with how easy you made this for me.

Thanks again,

-Rob

Link to comment
Share on other sites

Cool solution! Thanks for telling us :)

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

  • 1 month later...

Version 1.2.2.0 of the UDF has been released.

Please test before using in production!

For download please see my signature.

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

  • 5 weeks later...

Hello,

I'm having a weird error that I'm thinking the UDF is doing something weird with the returned array. I have Outlook 2016 with two different hotmail accounts added to it. I used to use _OL_ItemFind and $vFolder = "*", but it recently stopped returning emails from the 2nd account in Outlook. I updated the script to use _OL_FolderGet, but now the array returned by _OL_ItemFind on the 2nd account is messed up. Here is part of the code that has the problem:

 

#include <OutlookEX.au3>

Global $sAmazonClaimEmail = "claim@hotmail.com", $sAmazonBuyEmail = "buy@hotmail.com"

Global $oOutlook = _OL_Open(), $aCode, $sCodeList
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
Global $aOutlookClaimInbox = _OL_FolderGet($oOutlook, $sAmazonClaimEmail & "\Inbox"), $aOutlookBuyInbox = _OL_FolderGet($oOutlook, $sAmazonBuyEmail & "\Inbox")
If Not IsArray($aOutlookClaimInbox) Or Not IsArray($aOutlookBuyInbox) Then Exit MsgBox(48, "_OL_FolderGet", "Inbox Array Error")
Global $aItems = _OL_ItemFind($oOutlook, $aOutlookClaimInbox[1], $olMail, "@SQL=urn:schemas:httpmail:subject ci_startswith 'Someone sent you an Amazon.com Gift Card'", "", "", "Body,EntryID")
If IsArray($aItems) And UBound($aItems) > 1 Then
    _ArrayDisplay($aItems, "'Someone sent you an Amazon.com Gift Card")
    For $x = 1 To UBound($aItems) - 1
        $aCode = StringRegExp($aItems[$x][0], "(?s)Claim Code.+?(\w{4}-\w{6}-\w{4})", 1)
        $sCodeList &= $aCode[0] & @CRLF
        _OL_ItemDelete($oOutlook, $aItems[$x][1], $aOutlookClaimInbox[3])
    Next
Else
    MsgBox(48, "Someone sent you an Amazon.com Gift Card", "Could not find mail. @error = " & @error & ", @extended: " & @extended)
    Exit
EndIf

Global $aItems2 = _OL_ItemFind($oOutlook, $aOutlookBuyInbox[1], $olMail, "@SQL=urn:schemas:httpmail:subject ci_startswith 'An Amazon.com Gift Card you sent'", "", "", "EntryID")
If IsArray($aItems2) And UBound($aItems2) > 1 Then
    _ArrayDisplay($aItems2, "An Amazon.com Gift Card you sent before")
    _ArrayDelete($aItems2, 0)
    _ArrayDisplay($aItems2, "An Amazon.com Gift Card you sent after")
    For $x = 0 To UBound($aItems2) -1
        MsgBox(0,$x,$aItems2[$x])
        _OL_ItemDelete($oOutlook, $aItems2[$x], $aOutlookBuyInbox[3])
    Next
Else
    MsgBox(48, "An Amazon.com Gift Card you sent", "Could not find Gift Card recieved. @error = " & @error & ", @extended: " & @extended)
    Exit
EndIf

_OL_Close($oOutlook)

 

The loop through $aItems works just fine, but the script errors out on $aItems2 on the very first loop saying:

"C:\a.au3" (28) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
MsgBox(0,$x,$aItems2[$x])
MsgBox(0,$x,^ ERROR
->18:15:06 AutoIt3.exe ended.rc:1

Though the _ArrayDelete($aItems2, 0) does work as well as the two _ArrayDisplays. The array has 11 rows before the delete and doing a MsgBox(0,'',$aItems2[3]) before the _ArrayDisplay doesn't work either.

 

Also before the delete aItems2[0] displays 10 and copying it into notepad looks fine, but trying to do For $x = 1 To aItems2[0] was failing.

Link to comment
Share on other sites

Which version of the OutlookEX UDF do you run?

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

On 3.1.2017 at 0:26 AM, Baraoic said:

it recently stopped returning emails from the 2nd account in Outlook

What changed on your sytem? New version of the OutlookEX UDF installed? Changes made in your script? Something else?

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'm pretty sure I updated to 1.2.1 a while back and it worked when upgrading to 1.2.1. I just installed the 1.0.0 version, which I was using before and it didn't help. Other than that the only changes that come to mind are WIndows/Office updates and I have started using DNS level ad blocking. I use this script 1st week of every month and I can't remember for sure if it worked correctly in December, but I'm sure it worked back in November. I haven't changed the script in about 8 months until I started troubleshooting the Outlook issue.

 

Link to comment
Share on other sites

That's how I understand it:

  • OutlookEX UDF: Works with version 1.0.0 and 1.2.1
  • Script: Not changed in 8 months
  • Windows Updates: Might cause the problem
  • Office updates: Might cause the problem
  • DNS level add blocking: Might cause the problem

I suggest to add more error checking.
Now you do not check @error and @extended after a function call of the OutllokEX UDF. But this is the recommended method.

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

Problem with _OL_ItemFind

The commands are very great. They are easy to use and good documented. But i have trouble with _OL_ItemFind.

If there are more than ~ 300 mails in the folder a got an @error4 and @extended=1.

My parameter:  _OL_ItemFind($oOutlook, $Outlook_Folder, $olMail, "", "", "", "", 0)

This problem is constant with both udf versions. For more analysing a active the debug function "$__iOL_Debug" but than the call won't work.

 

PS:  I'm working for a script that export the outlook folder to my local share (with folder structure)

Edited by Clown007_de
Link to comment
Share on other sites

As you didn't specify properties to be returned by the function default properties (Subject,Body,CreationTime,LastModificationTime,Size) are being used.
There are members in your folder where property "Subject" isn't set (denoted by @extended = 1, the property index).

Either specify the properties you are interested in or I need to provide a modified function to ignore such errors.

 

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