Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Setup CDO for Office365.

Avatar of ZeropointNRG
ZeropointNRG
Flag of Australia image

Try this

fields.smtpusetls:=True

Open in new window

And try port 25.
Hi Z,

Those are good ideas. Unfortunately, I can't get them to work. I've done a fair amount of web research on this and came up with the following:

(1) The fields.smtpusetls field does not seem to exist. I can't find it (or the named constant cdoSMTPUseTLS) documented in the CDO Namespace, and using it in the AutoHotkey script doesn't work.

(2) There seems to be a time when port 25 worked on smtp.office365.com (there are posts of success with it a few years ago), but I'm guessing that Microsoft shut it down since so many ISPs now block 25. Most email sending has transitioned from 25 to 465 and 587.

(3) Found a reference to a fields.sendtls field, but setting it to True or 1 did not work. Also, I tried various values for smtpusessl, sendusing, and smtpauthenticate, but did not find anything that works.

(4) Found a reference to pmsg.SendTLS() — did not work.

(5) It's possible that Office 365 switched to NTLM authentication. I'm playing with that now. Will post back here if I discover anything interesting.

Regards, Joe
Hi Joe,

I remember an older script I had that wouldn't work with 587 because CDO.Message wasn't supported. Maybe things have changed.
Hi Z,
wouldn't work with 587 because CDO.Message wasn't supported
You may be right about that...I don't recollect ever using 587 in my AutoHotkey scripts that send email. All of my successful use with it has been with 465, which has worked on at least three different SMTP servers, including Gmail.

I just spent the last hour trying to get it to work with NTLM...no joy! This is a sticky wicket. I'm about ready to throw in the towel and wait for someone who knows more about Office 365 than I do. Regards, Joe
Yeah, I was told long ago to stop using CDO and move to Powershell and send-mailmessage because CDO was removed from exchange systems.
> CDO was removed from exchange systems

Good to know...I was unaware of that.
SOLUTION
Avatar of ZeropointNRG
ZeropointNRG
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Z,
First, let me start by saying that I know very little about PowerShell. With that out of the way, when I run the PS command, it says this:

Missing closing ')' in expression.

But there isn't...there are three left parens and three rights.

It goes on to say:

+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInExpression

I did a *RunAs in the AutoHotkey script so that it would run elevated and I set the PS execution policy to Unrestricted.

Do you know why it thinks there's a missing right paren?
I can get it to run in PS, but I can't get AHK to run -command. All it does is open PS then exit. None of the variables are being passed.

And to run this alone in PS you have to remove ! around the variables and remove the quotes. You have to add in the credentials directly too.

Tested with gmail.

Send-MailMessage -From 'from_email@gmail.com' -to 'to_email@gmail.com' -Subject 'No Changes Detected' -Body 'EmailBody' -BodyAsHtml -SmtpServer 'smtp.gmail.com' -port '587' -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('from_email@gmail.com', (ConvertTo-SecureString -String 'ThePassword' -AsPlainText -Force)))

Open in new window


Now to get it to work inside AHK ;/

I think we should just wait for the OP to test port 25 using the original CDO in your script.
Avatar of bfuchs

ASKER

Hi,

I think we should just wait for the OP to test port 25 using the original CDO in your script.

See attached.

Thanks,
Ben
Untitled.png
> I think we should just wait for the OP to test port 25 using the original CDO in your script.

I tried 25...doesn't work. Also tried 465...doesn't work.
Office365 can only use TLS which is 587 or 25. Since CDO can't use 587, he needs to try with smtp.office365.com using port 25 using CDO.

If that doesn't work, we have to use this method. Which I've fixed now, just trying to get it to hide!!!!
Stop the presses...drum roll, please...it works!

Z, you're a genius! PowerShell is the ticket! I have it working in an AutoHotkey script now. Doing some final tweaks and testing. Hope to be posting an updated script soon. Regards, Joe
> trying to get it to hide

Put two commas and Hide at the end of the Run command, e.g.:

Run,powershell.exe -command %PScmd%,,Hide

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried -WindowStyle Hidden that still doesn't work. Anyway, nice to hear you fixed it. I'll post my workaround in case you need something from it.

First, create a folder called WatchFile in w/e directory you want.

Then run this command from an elevated Powershell prompt; make sure to correct the path below.

This will create a hashed password file for use in the Powershell script inside Joes AHK. Only needs to be run once.

Get-Credential | Export-Clixml C:\WatchFile\wfile.xml

Enter your sending Email credentials into the dialog.
User name: = Your sending from email address.
Password: = Your password for that email.

Close the Powershell window.

Change the script below

From this;
SendEmail:
; change variables in here for your email service

EmailFrom:="MyEmail"
EmailTo:="MyEmail"
EmailPassword:="MyPWD"

pmsg:=ComObjCreate("CDO.Message")
pmsg.From:=EmailFrom
pmsg.To:=EmailTo
pmsg.Subject:=ProgramName . " Results"
pmsg.TextBody:=EmailBody
fields:=Object()
fields.smtpserver:="smtp.office365.com"
fields.smtpserverport:=587
fields.smtpusessl:=True
fields.sendusing:=2
fields.smtpauthenticate:=1
fields.sendusername:=EmailFrom
fields.sendpassword:=EmailPassword
fields.smtpconnectiontimeout:=60
schema:="http://schemas.microsoft.com/cdo/configuration/"
pfld:=pmsg.Configuration.Fields
For field,value in fields
  pfld.Item(schema . field):=value
pfld.Update()
Try pmsg.Send() ; Try so that script won't give dialog upon Send error
Return

Open in new window

To this;
SendEmail: ; change variables in here for your email service
EmailFrom:="FromEmail@email.com"
EmailTo:="ToEmail@email.com"
PScmd:="Send-MailMessage -from '" . EmailFrom . "' -to '" . EmailTo . "' -Subject 'No Changes Detected' -Body '" . EmailBody . "' -SmtpServer 'smtp.office365.com' -port '587' -UseSsl -Credential (Import-Clixml C:\WatchFile\wfile.xml)"
Run, powershell.exe -command %PScmd%,,Hide
^1::reload

Open in new window

Replace "C:\WatchFile\wfile.xml" with your files path.

Edit: Updated.
I see what you did there, nice ;) You turned it into a variable and you're hiding that xD

Well done, Joe!

Edit: Updated with the hash.
Thanks, Z. Yes, I put the PS command in a variable, but keep in mind that Hide as an option on Run is not there to hide that variable...it's there to launch the program (the target of the Run command) hidden.
Yup. I know : ) Cheers, Joe!
Z,
Thanks for posting the password hash code...always a nice idea to avoid a clear-text password. I haven't tried it yet, but it may come in handy some day. Regards, Joe
Avatar of bfuchs

ASKER

Hi Joe,

I just tested what you posted above and did not receive any email...
How long do I suppose to wait in order to get an email?

BTW, on google I see many sites claiming to have a way of sending with CDO on Office365, for example

https://community.smartbear.com/t5/TestComplete-Desktop-Testing/sending-mail-via-CDO-and-office365-com/td-p/132282

https://www.tachytelic.net/2018/12/email-vbscript-vba-office-365/

Thanks,
Ben
> How long do I suppose to wait in order to get an email?

They arrive here immediately. Do you have PowerShell's execution policy set correctly (Set-ExecutionPolicy) so that you can run PS scripts on the computer?
> on google I see many sites claiming to have a way of sending with CDO on Office365

The two you posted do not work...I tried both yesterday. I saw many others yesterday and the day before...tried them all...can not find anything that works. I posted a question on it at the AutoHotkey User Forum two days ago...it has 63 views...not a single response. I'm pretty well convinced that Microsoft has shut down the ability to use CDO for Office 365, but would love to be shown otherwise.
Avatar of bfuchs

ASKER

Do you have PowerShell's execution policy set correctly (Set-ExecutionPolicy)
Asking me to supply values to parameters.
What do i enter?

Thanks,
Ben
Unrestricted
And you need to run PS elevated (Run as administrator).
Avatar of bfuchs

ASKER

Done that, restarted the script but still not getting any emails...
What else could it be?

Thanks,
Ben
Let's see if my script is the problem or if PowerShell email is the problem. Put this in a new AutoHotkey script and run it (of course, put proper values in the first three Email variables):

EmailFrom:="YourOutlookAddress@outlook.com"
EmailTo:="YourToAddress@YourDomain.com"
EmailPassword:="YourPassword"
EmailSubject:="Test PowerShell Email"
EmailBody:="The time is: " . A_Now
PScmd:="""" . "Send-MailMessage -From '" . EmailFrom . "' -to '" . EmailTo . "' -Subject '" . EmailSubject . "' -Body '" . EmailBody
            . "' -SmtpServer 'smtp.office365.com' -port '587' -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('"
            . EmailFrom . "', (ConvertTo-SecureString -String '" . EmailPassword . "' -AsPlainText -Force)))" . """"
Run,powershell.exe -command %PScmd%,,Hide
ExitApp

Open in new window

Do you get an email from that?
Avatar of bfuchs

ASKER

Do you get an email from that?
No.
Thanks,
Ben
No.
Then the logic in my script for deciding when to send the email is not the problem...the culprit is that PowerShell is not sending the email. I don't know what to say...it works perfectly here. I can think of only two things: either PowerShell's execution policy is not set correctly or the email credentials are wrong. The 10-line AutoHotkey script in my previous post works fine here with my email credentials (From, To, Password)...the email arrives instantly...for example:

User generated image
The redacted From is an Outlook email address and the redacted To is a non-Outlook email address.
Avatar of bfuchs

ASKER

Hi,

I can think of only two things: either PowerShell's execution policy is not set correctly or the email credentials are wrong.

The PowerShell execution policy was set the way you instructed above. (see attached)

The email credentials are correct, just tested with another software and works.

What else can it be?

Thanks,
Ben
Untitled.png
Maybe your PATH variable doesn't have the path to PS in it. Mine has this in it:

C:\Windows\System32\WindowsPowerShell\v1.0\

Here's an easy test...put the fully qualified path to PS in the AutoHotkey script. In other words, change the Run command to this:

Run,c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command %PScmd%,,Hide
Avatar of bfuchs

ASKER

Hi Joe,

That didn't work either.

Thanks,
Ben
Ben,
The 10-line script works perfectly here every time on my W7 system. I was thinking that maybe you're on W10 and maybe that's an issue, but I just tested the 10-line script on a W10 system and that worked perfectly, too.

Here's another idea...I see in your screenshot that you're running a very old version of PS...it says Copyright 2009. My W7 system says Copyright 2012. My W10 system doesn't show a copyright date, but it is a later version than the W7 system. Issue this command in your PS window to display the PS version:

Get-Host | Select-Object Version

My W7 system is 3.0. My W10 system is 5.1. What's yours? In any case, I suggest updating to 5.1. Here's the download page for it:
https://www.microsoft.com/en-us/download/details.aspx?id=54616

I haven't done this myself yet on my W7 system, but the System Requirements section at that page does show W7 SP1 (there's no doubt that you're on W7, otherwise you'd have PS 5.1, which comes pre-installed in W10, and you wouldn't have a 2009 copyright in the PS window). Regards, Joe

Update: I'm now confident of my comment above about the version of PS. One of my W7 sandboxes still had a PS window with the 2009 copyright, like yours. The PS version was 2.0. The 10-line script did not work! I upgraded PS to 5.1 from the link I posted above. The 10-line script worked! Regards, Joe
How long do I suppose to wait in order to get an email?

This line near the top is set to 20, which is 20 minutes.

TimeIntervalMinutes:=20 ; time interval between checks in minutes

For testing purposes, set it to 1 minute and save. Close the script if it's already open and restart it.

BTW, on google I see many sites claiming to have a way of sending with CDO on Office365, for example

Exactly what I've been saying, which is why I wanted you to try port 25 using CDO originally.

Login to https://outlook.live.com
Click the settings gear at the top right.
Click "View all Outlook settings" at the bottom right.
Click "Mail" > "Sync email" and scroll to the "POP / IMAP" settings.
Make sure you see

"Server name: smtp.office365.com
Port: 587
Encryption method: STARTTLS"
Hi Z,

> This line near the top is set to 20, which is 20 minutes.

My interpretation of what Ben meant is how long does it take for O365 to send the email and how long does it take to arrive. In my testing, it comes in immediately. The script calls SendEmail as soon as it is run...the sleep (for 20 minutes or whatever you set it to) occurs only after the first run. I also have a version of the script that sends an email every time through the loop...I did that for testing purposes (and set the sleep time to 2 mins) so that I would always get an email. The code for that (in the file-does-exist path) is this:

  FileGetTime,CreatedTime,%FileToCheck%,C ; get file Created date/time
  FileGetTime,ModifiedTime,%FileToCheck%,M ; get file Modified date/time
  FormatTime,CreatedTimeDisplay,%CreatedTime%,yyyy-MM-dd_HH.mm.ss
  FormatTime,ModifiedTimeDisplay,%ModifiedTime%,yyyy-MM-dd_HH.mm.ss
  If ((CreatedTime<IntervalBeginTime) and (ModifiedTime<IntervalBeginTime)) ; see if it has been updated (created or modified)
    EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n"
                           . "File was not created or modified since " . IntervalBeginTimeDisplay
                           . "`nCreated: " . CreatedTimeDisplay . "`nModified: " . ModifiedTimeDisplay
  Else
    EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n"
                           . "File was created or modified since " . IntervalBeginTimeDisplay
                           . "`nCreated: " . CreatedTimeDisplay . "`nModified: " . ModifiedTimeDisplay
  Gosub,SendEmail

Open in new window

> I wanted you to try port 25 using CDO originally

Can you get 25 to work? I cannot. As I mentioned above, my first thought was that Microsoft shut it down since so many ISPs now block 25, but if you can get it to work, maybe it's my ISP that's the culprit.

Regards, Joe
Avatar of bfuchs

ASKER

Hi Experts,

I must close this thread and focus on another job.
May open a new thread at another opportunity...

Thanks very much!

Have a great weekend!
Hi Ben,
During this effort, I upgraded two W7/SP1 machines from PS 2.0 to PS 5.1 using the link I posted earlier. After doing the upgrade, the 10-line test script worked perfectly on both machines. But I want to give you a heads-up on the upgrade process...it isn't smooth!

In one case, I did it via the Install-WMF5.1.ps1 file that is one of the two files in the downloaded ZIP. It started out fine, but stalled at about the three-quarters mark. I let it sit there for about a half-hour, but it made no progress, so I cancelled the update process...or tried to...but the dialog stayed on the screen, so I eventually just did a shutdown. That worked, and when it came back up, it installed the update and PS 5.1 works fine.

In the second case, I tried the Install-WMF5.1.ps1 again, but this time it complained that WMF 3.0 was installed and that it can't install because of it (this, in fact, is documented). So I tried to uninstall WMF 3.0 via Programs and Features, but that hung. So then I decided to install from Win7AndW2K8R2-KB3191566-x64.msu directly (the other file in the downloaded ZIP), since it avoids the compatibility checks that Install-WMF5.1.ps1 does. Once again, it started out fine, but stalled at about the one-half mark. Again, I let it sit there for a half-hour, but it made no progress, so I cancelled the update process, but, like the first time, the dialog stayed on the screen, so I did a shutdown. That worked, and when it came back up, it installed the update and PS 5.1 works fine.

The bottom line is that when you do come back to this, I'm confident that it will work for you. You have a great weekend, too! Regards, Joe
You're right Joe, I figured it was because I added reload into the script and never closed it and just reloaded my changes.

Anyway, through my testing using port 465 on smtp.office365.com it never fired off on script execution unlike port 587. If I used port 587 using CDO, it would fire off straight away because we'd get the error 0x800. But for 465, it never threw an error until a minute passed. So I just ended up leaving it that way and waiting a minute regardless of the port or server. So I just made sure to wait at least 1 minute for confirmation. But I know now it only happened on port 465 using smtp.office365.com using CDO.

So using CDO;
smtp.office365.com failed on 587 and 465, as expected. Only port 25 worked for me.
smtp.gmail.com failed on 587, but worked for 25 and 465, as expected.

So if port 25 isn't working for him or you, indeed it's blocked at a firewall somewhere. ISP, local, w/e. (Which is a good thing.)

I only suggested it to get it working in your original script using CDO because the dummy email sending the alerts to his actual email didn't really need security and if it worked, great, no need to find a workaround.

So using Send-Mailmessage;
smtp.office365.com failed on 465, but works on 25 and 587.
smtp.gmail.com failed on 465, but works on 25 and 587.

But we've both confirmed every port except 465 works using Send-Mailmessage, for both servers. So if OP's isn't working, it's definitely as you suspected (PS) or his settings in the script or access.

There are a few things we need clarification on from OP if updating Powershell doesn't resolve it.

@ OP, Is your path set properly to the file you are watching?

FileToCheck:="D:\-=AHK_Scripts=-\WatchFile\WatchFile.ahk" ; full path of file to check

This is my path and file I used to watch for testing. Is your path correct?

Do you have a subscription to use Office365? If you do, check your sending email address has the settings described above by logging in online and checking the settings.

Or make a new alias under your account that owns the subscription and add it to outlook. And when you add it to outlook make sure to click advanced and check to set it up manually. Then on the next screen click the "Office365" icon. Even though Outlook does this for you automatically, just do it manually to be sure.

Then use that as your sending email address in the script.

If you don't have a subscription, or you do and it still doesn't work, then I suggest just making a dummy gmail account for sending like Joe said earlier and be done with it.

So it would look like this now if using gmail as the sending address and outlook as receiving.

EmailFrom:="YourDummyAccount@gmail.com"
EmailPassword:="Your Dummy Account Password"
EmailTo:="you@outlook.com"

If none of that works, Joe is right about your Powershell version being the culprit. Because we can both get this to work in different scenarios. Office365, Proton, Gmail, Hotmail. Port 25, 465(CDO), 587, all mixed in together sending from each and receiving from each. And both of our versions of Powershell are up to date or are at minimum version 2.
Thanks for the follow-up, Z.

> So using CDO; smtp.office365.com failed on 587 and 465, as expected. Only port 25 worked for me.

Very interesting that 25 worked for you on O365.

> smtp.gmail.com failed on 587, but worked for 25 and 465

Also interesting that 25 worked for you on Gmail.

> if port 25 isn't working for him or you, indeed it's blocked at a firewall somewhere. ISP, local, w/e

Good to know!

> So using Send-Mailmessage; smtp.office365.com failed on 465, but works on 25 and 587. smtp.gmail.com failed on 465, but works on 25 and 587.

I think you mean that Gmail fails on 587, but works on 25 and 465.

> it's definitely as you suspected (PS) or his settings in the script or access

I'm totally convinced that his old version of PS is the culprit. First, he said that the email credentials are correct...that he tested them successfully with another software. Second, when I tested on a system with the same PS copyright year as his screenshot shows (which is PS 2.0 here), it failed...and when I upgraded that system to PS 5.1, it worked.

> There are a few things we need clarification on from OP if updating Powershell doesn't resolve it.

Those are all good ideas for clarification, but I'm putting my money on the PS update.

> And both of our versions of Powershell are up to date or are at minimum version 2.

Correction on that here...my PS 2.0 did NOT work. My PS 3.0 and 5.1 work.

Regards, Joe
I think you mean that Gmail fails on 587, but works on 25 and 465.
Nah, 465 doesn't work for me using Send-Mailmessage.

I'm totally convinced that his old version of PS is the culprit. First, he said that the email credentials are correct...that he tested them successfully with another software. Second, when I tested on a system with the same PS copyright year as his screenshot shows (which is PS 2.0 here), it failed...and when I upgraded that system to PS 5.1, it worked.

Sounds about right. I disregarded his other app working because that could have access I just didn't bother asking.

But regarding PS v2. I was using v2 originally when I first came across Send-Mailmessage and others also said it required at least v2. Not sure what's changed or maybe it was the .net framework?... I still agree though. The version sounds like the problem.
Z, I think we've beaten this one to a pulp. We'll just have to wait until Ben circles back to it.

Great to collaborate with you on this...never would have come up with the PowerShell Send-MailMessage idea on my own. Regards, Joe
lol, I agree, Joe.

You would've figured something out I'm sure of it.

You too,

\o
Avatar of bfuchs

ASKER

Hi Experts,

You right, after updating the version the test email from PS works.

However the full script does not.

Getting below error

CheckFile results at 2019-08-25_15.16.13 for file:
Z:\Logs\UpdateCaspio.txt

File does not exist

See attached that file exists.

Also tried using the Servers IP (instead of Z:), same issue.

Thanks,
Ben
Untitled.png
> You right, after updating the version the test email from PS works.

Great news!

> File does not exist

Here's the code in the AutoHotkey script that produces that message:

If (!FileExist(FileToCheck)) ; see if the file exists
{
  EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n" . "File does not exist"
  Gosub,SendEmail
}

Open in new window


I'm confident that the FileExist call is correct (and it works perfectly here). To troubleshoot it, change that code to this:

FileAttributes:=FileExist(FileToCheck) ; get file attributes
MsgBox,4160,Debug File Attributes,File=%FileToCheck%`nAttributes=%FileAttributes%
If (!FileAttributes) ; see if the file exists
{
  EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n" . "File does not exist"
  Gosub,SendEmail
}

Open in new window

The only way that you would get the "File does not exist" email is if the attributes are null (an empty string). What does the message box say? Regards, Joe
Avatar of bfuchs

ASKER

Message says "Attributes=  "

The only way that you would get the "File does not exist" email is if the attributes are null (an empty string)
Right, but what does it mean, why are there no attributes and how do I create them?!

Thanks,
Ben
> Message says "Attributes=  "

What does "File=" say?
Avatar of bfuchs

ASKER

See attached.

Thanks,
Ben
Untitled.png
While it's true that you can create (set) some attributes, any existing file should have at least one attribute...that's why the doc at the FileExist command says this:
This function returns the attribute string (a subset of "RASHNDOCT") of the first matching file or folder:

    R = READONLY
    A = ARCHIVE
    S = SYSTEM
    H = HIDDEN
    N = NORMAL
    D = DIRECTORY
    O = OFFLINE
    C = COMPRESSED
    T = TEMPORARY

If the file has no attributes (rare), "X" is returned. If no file is found, an empty string is returned.

Since an empty string is seen as "false", the function's return value can always be used as a quasi-boolean value. For example, the statement if FileExist("C:\My File.txt") would be true if the file exists and false otherwise.

Both mapped drives and UNC paths work fine with FileExist.

If FileExist is not working, I can only think that the FileToCheck has a bad value in it or you do not have permission on that file or you changed some code in the script that created a bug.

Try this 5-line script:

FileToCheck:="Z:\Logs\UpdateCaspio.txt"
If (FileExist(FileToCheck))
  msgbox exists
Else
  msgbox does not exist

Open in new window

What happens? Then try it with a UNC (of course, change the address to yours):
FileToCheck:="\\192.168.0.100\Logs\UpdateCaspio.txt"

What happens? Regards, Joe
Avatar of bfuchs

ASKER

Try this 5-line script:
I get msg "Exists".

Thanks,
Ben
Avatar of bfuchs

ASKER

Then try it with a UNC (of course, change the address to yours):
In this case I also get "filet exists".

What does it mean?

And what is the solution?

Should I just try recreating this file?

Thanks,
Ben
Avatar of bfuchs

ASKER

@Joe,

Actually It looks like when testing UNC it was my mistake, I left out one sub folder name.

Will see now if that works and keep you posted.

Thanks,
Ben
> What does it mean?

It means that you introduced a problem into the big script.

> And what is the solution?

Fix it. :) My guess...bad file name or lack of permission.

> Should I just try recreating this file?

No. That's not the problem.
> Actually It looks like when testing UNC it was my mistake, I left out one sub folder name.

OK, but it should also work when mapped to Z, as it does with the 5-line script, so you probably left out the subfolder in the mapped drive, too.
Avatar of bfuchs

ASKER

Hi,

I left two versions running, one with the Z and one with the UNC, file wasn't changed last hour and didn't get any emails...

Thanks,
Ben
Untitled.png
Untitled.png
Is it "night hours" where you are? If so (and I suspect it is, since your EE profile says Brooklyn, NY), that explains it. If not, my guess is that you messed up the script in some way. I'm certain that the logic of when to send or not send the email is solid...it works perfectly here every time.

Attached is a version of the script that sends an email in all cases: (1) it is night hours, (2) file does not exist, (3) file was not created or modified, (4) file was created or modified. Of course, fill in your email credentials.

Each email will tell you what's happening. Regards, Joe
CheckFileSendMailInAllCasesOutlookPo.ahk
Avatar of bfuchs

ASKER

Hi Joe,
Is it "night hours" where you are? If so (and I suspect it is, since your EE profile says Brooklyn, NY), that explains it.
Correct, however logic was build to only skip after 22.15, while the file wasn't updated since 9.49 PM as shown in attached.
If ((A_Hour<6) or (A_Hour>22) or ((A_Hour=22) and (A_Min>=15))) ; check if time is between 10.15pm and 6.00am

Open in new window


If not, my guess is that you messed up the script in some way

Can you see what did I messed up here?

; Joe Winograd 21-Aug-2019
; with thanks to ZeropointNRG for the PowerShell idea and code
Version:="2.0"
#Warn,UseUnsetLocal ; warning on uninitialized variables
#NoEnv ; avoid checking empty variables to see if they are environment variables
#SingleInstance Force ; replace old instance immediately
SetBatchLines,-1 ; run at maximum speed

SplitPath,A_ScriptName,,,,ProgramName ; get name of script without path or extension
FileGetTime,ScriptDateTime,%A_ScriptFullPath%,M ; get script Modified date/time to use as Build in context menu About
FormatTime,Build,%ScriptDateTime%,yyyy-MM-dd_HH.mm.ss

; *** begin variables to change
FileToCheck:="\\ServerIP\appdev\Logs\UpdateCaspio.txt" ; full path of file to check
TimeIntervalMinutes:=20 ; time interval between checks in minutes
SafetyFactorSeconds:=5 ; go back in time some extra seconds to make sure it doesn't miss a change near beginning of time interval
EmailFrom:=""
EmailTo:=""
EmailPassword:=""
; *** end variables to change

EmailSubject:=ProgramName . " Results"
TimeIntervalSeconds:=TimeIntervalMinutes*60
TimeIntervalMilliSeconds:=TimeIntervalSeconds*1000
NextTime:=A_Now ; current time
EnvAdd,NextTime,%TimeIntervalSeconds%,Seconds ; add time interval to current time to get beginning time of next check

Menu,Tray,NoStandard ; do not use AutoHotkey standard context menu
Menu,Tray,Add,&About,ContextMenu ; first menu item is About
Menu,Tray,Add,E&xit,ContextMenu ; only other menu item is Exit
Menu,Tray,Default,&About ; default (on double-click) is About
FormatTime,NextTimeDisplay,%NextTime%,yyyy-MM-dd_HH.mm.ss
TrayTip:=ProgramName . " Version " . Version . "`nNext check time: " . NextTimeDisplay . "`n" . FileToCheck
Menu,Tray,Tip,%TrayTip% ; Windows limits tray tip to 127 chars, so file name could be truncated if it is long
TrayIconFile:="c:\Windows\System32\shell32.dll" ; use an icon from shell32.dll for the system tray
TrayIconNum:="-16790" ; looks like a file
Menu,Tray,Icon,%TrayIconFile%,%TrayIconNum%

RunAgain:
CurrentTime:=A_Now
FormatTime,CurrentTimeDisplay,%CurrentTime%,yyyy-MM-dd_HH.mm.ss ; format time for display so it is easier to read
If ((A_Hour<6) or (A_Hour>22) or ((A_Hour=22) and (A_Min>=15))) ; check if time is between 10.15pm and 6.00am
{
  Sleep,%TimeIntervalMilliSeconds%
  Goto,RunAgain
}
IntervalBeginTime:=CurrentTime
TimeIntervalSeconds:=TimeIntervalSeconds+SafetyFactorSeconds ; include safety factor in time interval
EnvAdd,IntervalBeginTime,-TimeIntervalSeconds,Seconds ; subtract time interval from current time to get beginning time of interval
FormatTime,IntervalBeginTimeDisplay,%IntervalBeginTime%,yyyy-MM-dd_HH.mm.ss ; format time for display so it is easier to read

If (!FileExist(FileToCheck)) ; see if the file exists
{
  EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n" . "File does not exist"
  Gosub,SendEmail
}
Else ; file exists
{
  FileGetTime,CreatedTime,%FileToCheck%,C ; get file Created date/time
  FileGetTime,ModifiedTime,%FileToCheck%,M ; get file Modified date/time
  If ((CreatedTime<IntervalBeginTime) and (ModifiedTime<IntervalBeginTime)) ; see if it has been updated (created or modified)
  {
    FormatTime,CreatedTimeDisplay,%CreatedTime%,yyyy-MM-dd_HH.mm.ss
    FormatTime,ModifiedTimeDisplay,%ModifiedTime%,yyyy-MM-dd_HH.mm.ss
    EmailBody:=ProgramName . " results at " . CurrentTimeDisplay . " for file:`n" . FileToCheck . "`n`n"
                           . "File was not created or modified since " . IntervalBeginTimeDisplay
                           . "`nCreated: " . CreatedTimeDisplay . "`nModified: " . ModifiedTimeDisplay
    Gosub,SendEmail
  }
}
EnvAdd,CurrentTime,%TimeIntervalSeconds%,Seconds ; add time interval to current time to get beginning time of next check
FormatTime,CurrentTimeDisplay,%CurrentTime%,yyyy-MM-dd_HH.mm.ss ; format time for display so it is easier to read
TrayTip:=ProgramName . " Version " . Version . "`nNext check time: " . CurrentTimeDisplay . "`n" . FileToCheck
Menu,Tray,Tip,%TrayTip% ; Windows limits tray tip to 127 chars, so file name could be truncated if it is long
Sleep,%TimeIntervalMilliSeconds%
Goto,RunAgain

ContextMenu:
If (A_ThisMenuItem="&About")
{
  MsgBox,4160,About %ProgramName%,%ProgramName% Version %Version%`nBuild %Build%
  Return
}
If (A_ThisMenuItem="E&xit")
{
  MsgBox,4388,%ProgramName% - Terminate?,Are you sure that you want to quit?
  IfMsgBox,Yes
    ExitApp
  Return
}

SendEmail:
PScmd:="""" . "Send-MailMessage -From '" . EmailFrom . "' -to '" . EmailTo . "' -Subject '" . EmailSubject . "' -Body '" . EmailBody
            . "' -SmtpServer 'smtp.office365.com' -port '587' -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('"
            . EmailFrom . "', (ConvertTo-SecureString -String '" . EmailPassword . "' -AsPlainText -Force)))" . """"
Run,powershell.exe -command %PScmd%,,Hide
Return

Open in new window



Thanks,
Ben
Correct, however logic was build to only skip after 22.15, while the file wasn't updated since 9.49 PM as shown in attached.
No! If it is night hours, the file dates are irrelevant...it doesn't even check! Look at the code...lines 42-26...if it is night hours, all it does is sleep again...never gets past line 46, where the file date checks are. If you want to do testing after 10:15pm, comment out lines 42-46. Regards, Joe
Avatar of bfuchs

ASKER

Hi,
So again what do I have to set this for if its okay for file not to get changed from 10.15 PM to 6.00 AM?
in addition, I got one email this morning at 6 that file has not been changed nothing else came after, is that the expected?
Thanks,
Ben
> So again what do I have to set this for if its okay for file not to get changed from 10.15 PM to 6.00 AM?

And again, as I said in the first thread, you don't have to do anything...I already built it to skip night hours (lines 42-46 in the script).

> I got one email this morning at 6 that file has not been changed nothing else came after, is that the expected?

Yes, if the file was updated (created or modified) in every time interval after that.

I suggest that you run the script attached to one of my previous posts in this thread for a day or two to make sure that it is working correctly. EE truncated the file name, which is really this:

CheckFileSendMailInAllCasesOutlookPowerShellBen.ahk

The name tells you exactly what it does, i.e., as I mentioned above, it sends an email in all cases: (1) it is night hours, (2) file does not exist, (3) file was not created or modified, (4) file was created or modified. That means you'll get an email every 20 minutes (or whatever you set the TimeIntervalMinutes variable to) around the clock, but if you do that for only a day or two, you'll see that it is functioning properly...if it isn't, let me know, and give me the text that is in the body of the email that you think signals incorrect operation. Regards, Joe
YES! So it's working? xD Great job, Joe!
Hi Ben,

Two things for you. First, I suggest that you stop using the Office 365 SMTP server and switch to the Gmail SMTP server. The reason is that Microsoft blocked my account this morning and I suspect they'll do the same to you. It's no doubt because of all the testing that I've done on the script over the last several days. When you start using it every day, they'll probably block you, too. I was working on enhancements to the script today (that's the second thing for you, discussed below) and all of a sudden I wasn't getting emails when I was sure that the script's logic was correct. I then logged into my Outlook email (which I never use for real...only for test/dev) and found an email that said this:
We noticed some unusual activity in your Outlook.com account. To help protect you, we've temporarily blocked your account.
I tried to unblock it...twice...did not work...still could not send email via PowerShell. I replied to the email asking how to unblock it now and how to prevent this from happening in the future. I got this reply:
This email address is not monitored. Please visit the Microsoft Community at http://answers.microsoft.com/ to learn more about our services, find answers to your questions, and share your feedback.

Sincerely,
Outlook.com Team
There's no way that I'm going to waste my time trying to get this resolved at http://answers.microsoft.com/ — if you wish to do it, good luck. I'll be using Gmail in all my AutoHotkey scripts, as I was before this adventure started. :) Btw, both CDO and PowerShell work with Gmail.

Second, as mentioned above, I made some enhancements to the script, as follows:

Release Notes for CheckFile V3

(1) Generalized the night hours code so that the time check for 10:15pm to 6:00am is not hard-coded. There are now these new variables that can be easily changed:

NightHoursBeginTime:="2215" ; 10.15pm (HHMM format - HH=00-23, MM=00-59)
NightHoursLengthMinutes:=465 ; 7 hrs and 45 mins (0 means there are no night hours, i.e., always check file)

If NightHoursLengthMinutes is set to 0 (zero), it bypasses the check for night hours. This provides an easy way to test during night hours without having to change any code.

(2) Added a variable called AlwaysSendEmail that may be set to True or False. When True, it sends an email in all logic paths. This is very helpful for testing/troubleshooting.

(3) Added a variable called PSexe for the full path to the PowerShell executable. If your PSModulePath environment variable does not exist or does not have the correct path to PS in it, you can set the full path here (without having to fix the environment variable).

(4) Added variables for the SMTP server and SMTP port to make it easier to change the email account that you use for sending.

(5) Added sections for O365 and Gmail with variables for EmailFrom, EmailTo, EmailPassword, SMTPserver, and SMTPport.

The new AutoHotkey script is attached. Regards, Joe
CheckFileV3.ahk
> Great job, Joe!

Thanks, Z...but let's not forget that your PowerShell code is crucial to the solution! Regards, Joe
Avatar of bfuchs

ASKER

Hi Joe,

Just started running your latest script at 9.33 PM, and file was last modified 8.48 PM, wasn't I suppose to immediately receive an email?
Now at 10.00 PM I should have been receiving another email, no?

Also created Gmail email address and saved there as well.

Tried with both, Mapped drive Z and UNC, none of them works.

Thanks,
Ben
Hi Ben,

> wasn't I suppose to immediately receive an email?

Yes, if you left AlwaysSendEmail set to True and/or left TimeIntervalMinutes set to 20.

> Now at 10.00 PM I should have been receiving another email, no?

Yes, if you left the value of TimeIntervalMinutes set to 20 (obviously, it depends on that).

> Tried with both, Mapped drive Z and UNC, none of them works.

Works perfectly here every time with mapped drive and UNC. Worked once at the beginning of the day with O365, but then the block occurred. After that, have received around a dozen emails from it via Gmail during testing. If it's not working for you, I'm nearly certain that it has nothing to do with the script's logic, but that we're back to the issue of sending email not working for you. Here's a new version of the small test-send-mail script based on the new V3 code:

PSexe:="powershell.exe" ; if your PSModulePath environment variable does not have PS in it, you can set the full path here
EmailSubject:="Test sending email with PowerShell in AutoHotkey script"
EmailBody:="The time is: " . A_Now

; Office365
EmailFrom:="YourOutlookFromAddress@outlook.com"
EmailTo:="YourToAddress@domain.com"
EmailPassword:="YourOutlookPassword"
SMTPserver:="smtp.office365.com"
SMTPport:="587"

; Gmail
EmailFrom:="YourGmailFromAddress@gmail.com"
EmailTo:="YourToAddress@domain.com"
EmailPassword:="YourGmailPassword"
SMTPserver:="smtp.gmail.com"
SMTPport:="587"

PScmd:="""" . "Send-MailMessage -From '" . EmailFrom . "' -to '" . EmailTo . "' -Subject '" . EmailSubject . "' -Body '" . EmailBody
            . "' -SmtpServer '" . SMTPserver . "' -port '" . SMTPport . "' -UseSsl -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList ('"
            . EmailFrom . "', (ConvertTo-SecureString -String '" . EmailPassword . "' -AsPlainText -Force)))" . """"
Run,%PSexe% -command %PScmd%,,Hide
ExitApp

Open in new window

Try it with both O365 and Gmail. If the new V3 big script doesn't send an email, then I'm sure the test-send-mail small script above will also not send an email. Regards, Joe
Great updates, Joe!

Yeah I've seen this block before. To get it unblocked there was a link to get white listed and you had to explain what your script did...Too much hassle.
> Great updates, Joe!

Thanks, Z.

> To get it unblocked there was a link to get white listed and you had to explain what your script did

Interesting! Didn't see that. I followed a link in the email to unblock it...didn't ask for any info...all it did was send a "Microsoft access code" to my phone, but entering the code did not unblock it...tried twice, then gave up.
Yeah lol. This was an MVP at Microsoft that gave the link. He went on to ask what the script did, etc...I mean, really. What does it do? It sends an email alert every hour or something BRO!...He literally states everything in his OP. I'm like WHAT? lol...These people at MS are crazy. I never even bother going there anymore. And I gather you've had the same experience with them. But he did point to the white list so you can spam yourself with alerts. I can't find it though. ;/
A white list?! Would be nice to find that. In the meantime, I decided to take another shot at it...hadn't tried in the last 8 hours or so...lo and behold...it worked! Go figure. :)
Ahh, do you use a VPN? I noticed for myself sometimes port 25 didn't even work and then I changed servers on my VPN and got it to work again.
Nope...don't use a VPN. Interesting that a server change got 25 working again.

Well, 3:00am here...time for some shut-eye.
Hi Z,

Thanks for finding that link! Will be putting that in my bag-o-tricks! :) In the meantime, I'm running the new V3 script via O365 for the next 24 hours with AlwaysSendEmail=True and TimeIntervalMinutes=120. With some luck, Microsoft won't block the account for sending one email every two hours. Also, I changed the email Subject to include the current time so that the Subject is different on each email...maybe their spam detector doesn't like seeing emails with the same Subject.


Hi Ben,

The updated AutoHotkey script with the enhanced Subject that includes the current time is attached as Version 3.1. As I mentioned to Z, I just started running it against a network-mapped file that I gave the same name and location as your file (Z:\Logs\UpdateCaspio.txt). The first email came in fine from O365 with this Subject:

CheckFileV3.1Joe Results at 2019-08-27_09.43.33

And this body:

CheckFileV3.1Joe results at 2019-08-27_09.43.33 for file:
Z:\Logs\UpdateCaspio.txt

File was not created or modified since 2019-08-27_07.43.28
Created: 2019-08-26_23.23.10
Modified: 2019-08-26_23.23.10

I'll let you know how it goes during the next 24 hours.

Btw, in V3.1, I put the O365 and Gmail statements in separate comment blocks. Remove one set of the comment tags (the /* and */) to un-comment either the O365 or Gmail code and, of course, enter the proper email credentials.

Regards, Joe
CheckFileV3.1.ahk
Hi Ben,
Two hours have passed and I received the second email with this Subject:

CheckFileV3.1Joe Results at 2019-08-27_11.43.33

And this body:

CheckFileV3.1Joe results at 2019-08-27_11.43.33 for file:
Z:\Logs\UpdateCaspio.txt

File was created or modified since 2019-08-27_09.43.23
Created: 2019-08-27_10.19.39
Modified: 2019-08-27_10.19.39

There are only four logic paths in the AutoHotkey script that send an email. The first, in my previous post, is "not created or modified". The second, shown above in this post, is "created or modified".

The third path is "does not exist", which I just tested via a modified script with FileToCheck set to a file that does not exist...it worked. Here's the Subject:

CheckFileV3.1TestNotExist Results at 2019-08-27_12.20.50

And the body:

CheckFileV3.1TestNotExist results at 2019-08-27_12.20.50 for file:
Z:\Logs\UpdateCaspioXXX.txt

File does not exist

The fourth path is "Night hours", which I just tested via a modified script that has NightHoursBeginTime:="1200" and NightHoursLengthMinutes:=60, which is now...and it worked. Here's the Subject:

CheckFileV3.1TestNightHours Results at 2019-08-27_12.35.59

And the body:

CheckFileV3.1TestNightHours results at 2019-08-27_12.35.59 for file:
Z:\Logs\UpdateCaspio.txt

Night hours - did not check

Thus, this shows that all four logic paths in the script work. Regards, Joe

P.S. I decided to terminate the 24-hour test as I'm confident that the script is working perfectly.here.
Excellent job, Joe. So much work you put into this. You deserve a beer ;)
Thanks for the compliment, Z...I really appreciate it!
Avatar of bfuchs

ASKER

Hi Joe,

Now I'm receiving emails in all cases (as you mentioned above), how do I set it up to only receive emails if file was not changed?

Also is it possible to add a space between the date and the time that will run next?

BTW, this only works by me with UNC, while on mapped drive I still get the message below.

CheckFile - Copy results at 2019-08-27_16.38.42 for file:
Z:\Logs\UpdateCaspio.txt

File does not exist

Thanks,
Ben
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thank you very much Joe!
You're very welcome, Ben, it's been an extremely interesting thread. Regards, Joe
Avatar of bfuchs

ASKER

Hi Joe,

I'm not done yet-:)

First we discussed the script logic, then the email process, now comes the schedule portion...(let me know if you prefer to open a new thread for this).

I left it running for the last couple of hours, and didn't get emails as expected, however since 12 AM it started sending again...

See attached.

Thanks,
Ben
Untitled.png
Sorry, Ben, my bad...when I parameterized the night hours check (instead of leaving it hard-coded for 10:15pm-6:00am), I introduced a bug. The bug occurs only when the begin time and end time of the night hours are in different days, i.e., when the end time crosses midnight. Unfortunately, when I tested night hours, I set the begin and end time in the same day for expediency, so the bug didn't hit. I'll fix it today and will post an updated script...before tonight's night hours begin. :) Regards, Joe
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Hi Joe,

Running your latest for hours and its not sending any emails.
File was last updated 1.5 hours ago.

Thanks,
Beb
Hi Ben,
Has been working perfectly here for several hours. Please do this:

(1) Exit the script.
(2) Edit the script and change the AlwaysSendEmail line to this:
      AlwaysSendEmail:=True
(3) Save the script and re-run it.

It should immediately send an email. Post the body of the email. Regards, Joe
One other thing. If you don't immediately get an email after doing the steps above, it probably means that your email is not not sending (blocked account, bad credentials, whatever). In that case, to prove that the rest of the script is working, do this:

(1) Keep the change from step (2) in my previous post.

(2) Edit the script and change the TestRun line to this:
     TestRun:=True

(3) Save the script and re-run it.

You should immediately get a message box (instead of an email) showing what would have been sent in an email. The message box should have this in it (of course, with different date-time stamps, and along with a bunch of other stuff):

File was not created or modified since 2019-08-28 15.12.35
Created: 2019-08-27 00.13.28
Modified: 2019-08-27 16.40.08

Does it?
Avatar of bfuchs

ASKER

Hi Joe,

Sorry, Ben, my bad...when I parameterized
Well this time was my bad...when I reentered my Gmail credentials, something was not good...-:)

Will keep testing.

Thanks,
Ben
Whew! :)
Hi Ben,

I made some significant enhancements to CheckFile, documented in the Release Notes below for Version 4. The new V4 AutoHotkey script is attached to this post. Regards, Joe


Release Notes for CheckFile Version 4

• Added a logfile feature to aid in testing/troubleshooting. There's a new variable in the "variables to change" section called Logfile. If its value is null (""), it means there is no logfile. If its value is not null, it must be the full path to a plain text file that is the logfile. The default in the attached V4 script does have a logfile, which it puts here:

A_Temp . "\" . ProgramName . "_" . FilenameTime . ".log"

A_Temp is the standard Windows location for the temp folder, typically here:

c:\Users\<UserName>\AppData\Local\Temp\

The FilenameTime in file name is the date/time that the program was run, in this format:

yyyy-MM-dd_HH.mm.ss

Note that it includes seconds (ss) in the file name so that there are never any duplicate file names. So, a sample logfile name is:

c:\Users\Ben\AppData\Local\Temp\CheckFileV4_2019-08-29_09.48.49.log

You may, of course, put in elsewhere and make it a different file extension, which could result in this, for example:

c:\Temp\CheckFileV4_2019-08-29_09.48.49.txt

If the Logfile variable is not null, the SendEmail subroutine writes a record to the logfile, whether or not it is a testing run (i.e., the value of TestRun does not matter).

This logfile enhancement, combined with AlwaysSendEmail:=True, makes testing/troubleshooting significantly easier, as everything that you need to know about the operation of the program will be in the logfile, which is easily viewed with any text editor, such as the built-in Notepad.

• Added Open Logfile choice in the system tray context menu to support the new logfile feature above. This context menu item is present only when a logfile is specified, i.e., when the new Logfile variable is not null. Selecting this item opens the logfile in whatever program owns the file extension of the specified logfile, such as Notepad for a LOG or TXT file type.

• Changed Build not to use the DateTimeSeparator. Instead, there is always an underscore between the date and time.

• Changed TestRun from a Boolean variable (True or False) to an integer, as follows:

0: Normal run (i.e., not a test run) - send email
1: Test run - do not send email - display message box
2: Test run - do not send email - do not display message box

Obviously, TestRun:=2 makes sense only in conjunction with the logfile, since without emails or message boxes, the logfile is the only way to see the program's operation.

• Added some error checking on the variables entered in the "variables to change" section.

• Fixed a bug where where the Next time check display when hovering on the system tray icon was not always updated.
CheckFileV4.ahk
Avatar of bfuchs

ASKER

Hi Joe,

We are getting closer to finish this product...


While testing version 3 I found the following.

received message below

CheckFile Version 3.3 Build 2019-08-28 17.03.11 results at 2019-08-29 12.43.20 for file:
\\ServerIP\appdev\logs\UpdateCaspio.txt

File was not created or modified since 2019-08-29 12.20.15
Created: 2019-08-21 02.43.18
Modified: 2019-08-29 12.18.23


Which means it did not wait for 30 minutes since the file was updated to send this message.

Thanks,
Ben
> results at 2019-08-29 12.43.20 for file

That means the check ran at 12.43.20.

> File was not created or modified since 2019-08-29 12.20.15

That means the time interval to check (with the safety factor) started at 12.20.15. That makes the interval 23 minutes and 5 seconds. I'm guessing that you have the time interval set at 23 minutes and the safety factor at 5 seconds, although the accuracy of the sleep time is not always precise...it can vary depending on what else is happening on the computer at the time...and, of course, the program itself takes some time to run.

> File was not created or modified since 2019-08-29 12.20.15
> Created: 2019-08-21 02.43.18
> Modified: 2019-08-29 12.18.23

So, the program is correct...the file was not created or modified since 12.20.15 (it was modified at 12.18.23, before the beginning of the current time check interval).

> Which means it did not wait for 30 minutes since the file was updated to send this message.

I do not understand that comment. The program sent that email 23 minutes and 5 seconds after the previous check. What does "did not wait for 30 minutes" have to do with it?

Regards, Joe
Avatar of bfuchs

ASKER

Hi Joe,

Sorry was my mistake, thought logic was to keep testing every 20 minutes if file was not updated within last half hour...

So that means by now program is fully functional?

Congratulations!!

Thanks,
Ben
> thought logic was to keep testing every 20 minutes if file was not updated within last half hour

Nope. It always checks every 20 minutes (or whatever TimeIntervalMinutes is set to).

> So that means by now program is fully functional?

I think so, especially Version 4. The logfile has been a great feature for testing, as you can run it all you want without getting a flood of emails (or message boxes), and yet be able to see everything that the program would have emailed during a normal run.

> Congratulations!!

Thanks! It has been a fun project. Regards, Joe