Jump to content
water

OutlookEX UDF: Example scripts

Recommended Posts

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I may have spoken too soon.  Interestingly enough, the script seems to have some problem with the EntryID it obtains as a command line parameter.  It appeared there would be no problem, but when I run the following I get an error (@error = 2) showing that the item could not be found.  EntryID might be wrong.  any suggestions on why this would be?

Global $oOutlook = _OL_Open()
Global $aOL_Properties = _OL_ItemDisplay($oOutlook, $CmdLine[1])
 
Is AutoIt somehow misinterpreting the EntryID that is coming in from the command line parameter?  Does the EntryID somehow change after it is captured by the Macro?
 
Any help would be appreciated.

Share this post


Link to post
Share on other sites

Can you write the EntryID you get from $CmdLIne[1] to the Console or a MsgBox to check the content?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yes.  Here is an example:

00000000A6606C08D493D442B6D442E5BB7A8DF707004A1E4AFD3D82804DBAF7CCC131322BA400000F53119B00005A330D503E3FC547BFF6A54EBC28A3D8006CCFB71C570000

Share this post


Link to post
Share on other sites

Have you tried the approach I use in the _OL_Example_SentMail_Event.au3? It "monitors" the sent items folder.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have a working version of that that I have been using myself for a long time.  It works well and I can continue to use it.  However, on a rare occasion an error may occur in the script due to something unexpected and it must be restarted.  With the approach I am pursuing the script would be run fresh every time an email is sent and it would be very fault tolerant and use fewer system resources.  The EntryID would be passed to the script and the email manipulated accordingly.

I have a second script that I use for received emails where I select the emails to be manipulated and then use a macro to launch the script.  It is more fault tolerant than my sent email script.  It is what I am trying to pattern this rebuild around.

I have two ideas:

it seems possible that the EntryID is changing from the one I am collecting with the macro.  My research shows that the EntryID changes when an email is moved from folder to folder.  Perhaps the EntryID the macro is returning is the one given when it is in the outbox before it goes to the sent items folder.  The method in the macro is "Application_ItemSend" and I believe allows manipulation of the email before it is actually sent.  That would account for the script being unable to locate the item based on that EntryID.  What I really need is an "Application_ItemSent" method, though that does not exist.  Alternatively a way to tell the macro to send the email and then poll the EntryID from the Sent Items folder.  

Alternatively, I would need a some programming in the script to identify and return the EntryID of the most recently sent email.  I am not sure exactly where to begin on that.

Any help on either of these approaches would be greatly appreciated.

Share this post


Link to post
Share on other sites

I just noticed that you posted in the Example Scripts thread. Can we move it to the GH&S thread?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hello – I wrote a simple program to monitor the Outlook outbox for unset items. The program works fine, but there now seems to be an issue sending any item that were in the outbox when the program ran. The items are usually stuck in the outbox because the mailbox is full and when you free up some space the items will be automatically sent. After running the code below, there is no attempt to send items when I free up space, close and reopen outlook, reboot the computer, and select send/receive all folders. I now have to open the item in the outbox and send it manually. This occurs on Outlook 2010/Exchange. At home, where I'm testing the program, I only have Outlook 2010 set up with dummy pop/smtp info to keep the items in the outbox. I can press "send all" and the attempt is made until I run the code and nothing occurs when "send all" is selected. The UDF version is 0.10.0.0. Any ideas? Thanks 

 

#include <OutlookEX.au3> 

Global $oOutlook = _OL_Open() 

Global $aItems = _OL_ItemFind($oOutlook, "*Outbox", $olMail, "", "", "", "EntryID") 

_OL_Close($oOutlook)

Share this post


Link to post
Share on other sites

Can you please check the "Sent" property of those mail items?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Thank you for the help. I went back and sent a new item and before the below code runs, I can see a Sent time in Outlook. After the code runs, the Sent time now says none. After the code runs, I have 1 new property and 1 that has changed.
 
Before the code runs:
 
[23]|EntryID|000000005A4431201BE3B94890692B49F97075D564022000|1
[67]|Saved|True|6
 
After the code runs:
 
[23]|EntryID|000000005A4431201BE3B94890692B49F97075D564022000|0
[24]|EntryID|000000005A4431201BE3B94890692B49F97075D564022000|1
[68]|Saved|False|6
 
#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
Global $aOL_Item = _OL_ItemFind($oOutlook, "*Outbox", $olMail, "", "", "", "EntryID")
Global $aOL_Properties = _OL_ItemGet($oOutlook, $aOL_Item[1][0])
_ArrayDisplay($aOL_Properties)
_OL_Close($oOutlook)
 
Here are the after properties in case they help(personal info removed)
 
[0]|92|3|
[1]|Actions||0
[2]|AlternateRecipientAllowed|True|6
[3]|Application||0
[4]|Attachments||0
[5]|AutoForwarded|False|6
[6]|AutoResolvedWinner|False|6
[7]|BCC||1
[8]|BillingInformation||1
[9]|Body|t
|1
[10]|BodyFormat|2|3
[11]|Categories||1
[12]|CC||1
[13]|Class|43|3
[14]|Companies||1
[15]|Conflicts||0
[16]|ConversationID|4CCEA980B2349C4E67D0412000A20817|1
[17]|ConversationIndex|01CF44A2F37B6F1C3901D708403B8554700F4B20E9DA|1
[18]|ConversationTopic|t|1
[19]|CreationTime|20140320201444|5
[20]|DeferredDeliveryTime|45010101000000|0
[21]|DeleteAfterSubmit|False|6
[22]|DownloadState|1|3
[23]|EntryID|000000005A4431201BE3B94890692B49F97075D564022000|0
[24]|EntryID|000000005A4431201BE3B94890692B49F97075D564022000|1
[25]|ExpiryTime|45010101000000|0
[26]|FlagRequest||1
[27]|FormDescription||0
[28]|GetInspector||0
[29]|HTMLBody|<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>t<o:p></o:p></p></div></body></html>|1
[30]|Importance|1|3
[31]|InternetCodepage|20127|3
[32]|IsConflict|False|6
[33]|IsMarkedAsTask|False|6
[34]|ItemProperties||0
[35]|LastModificationTime|20140320201619|5
[36]|Links||0
[37]|MarkForDownload|0|3
[38]|MessageClass|IPM.Note|1
[39]|Mileage||1
[40]|NoAging|False|6
[41]|OriginatorDeliveryReportRequested|False|6
[42]|OutlookInternalVersion|144760|3
[43]|OutlookVersion|14.0|1
[44]|Parent||0
[45]|Permission|0|3
[46]|PermissionService|0|3
[47]|PermissionTemplateGuid||1
[48]|PropertyAccessor||0
[49]|ReadReceiptRequested|False|6
[50]|ReceivedByEntryID||0
[51]|ReceivedByName||1
[52]|ReceivedOnBehalfOfEntryID||0
[53]|ReceivedOnBehalfOfName||1
[54]|ReceivedTime|20140320201400|5
[55]|RecipientReassignmentProhibited|False|6
[56]|Recipients||0
[57]|ReminderOverrideDefault|False|6
[58]|ReminderPlaySound|False|6
[59]|ReminderSet|False|6
[60]|ReminderSoundFile||1
[61]|ReminderTime|45010101000000|0
[62]|RemoteStatus|0|3
[63]|ReplyRecipientNames||1
[64]|ReplyRecipients||0
[65]|RetentionExpirationDate|45010101000000|5
[66]|RetentionPolicyName||1
[67]|RTFBody|REMOVED|0
[68]|Saved|False|6
[69]|SaveSentMessageFolder||0
[70]|Sender||0
[71]|SenderEmailAddress|xxxx@Yahoo.com|1
[72]|SenderEmailType|SMTP|1
[73]|SenderName|xxxx|1
[74]|SendUsingAccount||0
[75]|Sensitivity|0|3
[76]|Sent|False|6
[77]|SentOn|45010101000000|5
[78]|SentOnBehalfOfName||1
[79]|Session||0
[80]|Size|3411|3
[81]|Subject|t|1
[82]|Submitted|False|6
[83]|TaskCompletedDate|45010101000000|0
[84]|TaskDueDate|45010101000000|0
[85]|TaskStartDate|45010101000000|0
[86]|TaskSubject|t|1
[87]|To|test@test.com|1
[88]|ToDoTaskOrdinal|45010101000000|0
[89]|UnRead|True|6
[90]|UserProperties||0
[91]|VotingOptions||1
[92]|VotingResponse||1

Share this post


Link to post
Share on other sites

Oh. I realized my previous post may be confusing. When I say "Before the code runs:" I meant to say those are the properties returned when the code 1st runs and the message seems to be fine. The after is when I run the exact same code the 2nd time without changing anything and the properties change. I'm not smart enough to get all those properties without your code :) To answer your original question, the sent property is False each time I run the code. 

Share this post


Link to post
Share on other sites

As you can see property "Saved" is set to False. Looks like saving the changed item didn't work. That's why Outlook doesn't send the item because it is still being "edited".

Make sure the property is set to True. Then sending should work too (I hope).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks. I'm not changing or doing anything with the unset item. If I open Outlook and Autoit side-by-side and execute 

Global $aOL_Item = _OL_ItemFind($oOutlook, "*Outbox", $olMail, "", "", "", "EntryID")

the "Sent" field immediately changes to "None". and I guess that is what causes the 2nd EntryID and Sent to be set to False. After that, I tried to save the item, and even change it and save, but the "Send All" still does nothing.

Share this post


Link to post
Share on other sites

I stepped through the code and soon as this line in the __OL_CheckProperties function runs, I see the properties change.

$oProperty = $oItem.UserProperties.Find($aTemp[1], Not $bItemProperties) ; Search Itemproperties or UserProperties

It does not seem to be an issue with your UDF because I tried some VBscript code and the same issues occurs, I guess it's an issue or limitation of the com interface.

In the VBScript code below, as soon as the CreationTime is referenced, the message gets modified. However, I did find that code useful since I can count the items in the Outbox without referencing its properties. That limits what I wanted to do, but at least the mail gets sent out automatically on cleanup. I just need to figure out how to use your UDF to count items without using the properties. Thanks again for the help.

 

Set objFolder = objNamespace.GetDefaultFolder( OUTBOX )
For Each objItem In objFolder.Items
    If DateDiff( "d", objItem.CreationTime, Now ) > intMax Then
        intOld = intOld + 1
        objItem.Delete
    End If
Next

Share this post


Link to post
Share on other sites

The Items property of the Folder object returns a collection of items. The count property of this collection should give you the number of items in the folder.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for the tip. I updated my program to only check the count of items since reading any property of an item in the outbox seems to modify it and it will no longer be sent automatically . I tried OutlookSpy and it does the same thing,

Share this post


Link to post
Share on other sites

Strange! Accesing a property changes it? Somehow reminds me of Schrödingers cat ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Version 1.1.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 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

×
×
  • Create New...