Not able to send automated mails by task scheduler and python - email

I use a python script to send mails. The script runs a VBA macro.
I'm scheduling the python script to run at a particular time.
Configuration
My trust settings in Outlook has all macros enabled.
I'm running the task with highest priority too.
Problem
I am able to send mails if I run the script manually.
However, when I try to run it via Windows Task Scheduler, mails are not being sent.

Try a different scheduler and see if this works.
For example Splinterware system scheduler.
Trying a different scheduler can help you figure out if the problem is
a setting in the scheduler (like not having the password entered)
or in your Python script (which would affect all schedulers)

There is a way to send emails from Outlook automatically without the use of Task Scheduler. It is outlined neatly here.
It uses recurring reminders, so Outlook must be kept running at all times (but the macro is only executed when the reminder fires).

Related

Do not send emails to subscribers in the Reporting Configuration. Kentico 9

After creating a subscription in the Reporting Configuration, the emails are not sent at the specified time, but if you perform any actions on the site, the emails will be sent. This is the problem of the virtual machine on which the site or IIS is deployed. Or does the feature Kentico.
Prompt in what there can be a problem and how the system of sending of emails inin the Reporting Configuration works.
This is a correct behavior. Kentico checks for e-mails that are to be sent at the end of requests which means that if there are no requests, no e-mails are sent. If you need some tasks to be send at a specified time, you need to use Windows scheduler and configure task (e-mmail sending) to use it. See official documentation for more detail.s
Another option to Enn's, is to use a service like UpTime Robot to continually visit your page (like every 5 minutes), this not only generates a request but also will help keep your site awake and from going to sleep if you can't manually set the Worker Processor to never go to sleep.
Windows Scheduler is the most reliable, but UpTime robot has worked well for us.
https://uptimerobot.com/
Under the "Scheduled Tasks" module there is a schedule task called "Report subscription sender". This task runs every minute and is responsible for checking your subscriptions and sending e-mails based on your configuration. This task runs within the Kentico instance. By default IIS will put the site/app pool to sleep after x (default 20) minutes of idle and the scheduled tasks are no longer able to run. When you hit the site it wakes the process back up and the scheduled task is able to run again. You can go into IIS and configure the "Idle Time-out (minutes)" for the application pool see this link https://patrickdesjardins.com/blog/iis-no-sleep-idle-and-autostart-with-values for a pretty good illustration. You can also adjust the app pool recycle intervals but that is probably not necessary for your issue.
The other option, as mentioned by Enn, is to install the Kentico Scheduler Windows service which always runs and configure that scheduled task to run in the service.

Task Scheduler - MS Access can't send email via MS Outlook

Recently we updated our systems to Office 2016. I have a scheduled task that reads information in an MS Access DB and then sends this information to a mail recipient via Outlook. All was fine until the upgrade.
The Scheduled task launches a .bat file which opens MS Access, calls a function, performs a task and then send the the information via email using outlook.
When I run the batch file manually by double clicking on it, it works as intended and sends the email. However, when I run through Task Scheduler it does not work. I know for certain that it opens the MS Access file and can read, but for some reason it fails to send the email. I have lowered all security setting to no avail.
The scheduled task runs with the highest privileges and all was fine before the upgrade.
Does anyone have any suggestions.
Outlook has security settings that will prevent an application from sending e-mail through it programmatically. It will use a popup dialog to ask for permission to send the e-mail. While I have successfully gotten rid of the popup and made Access send through Outlook while Outlook is open (both manually and as a scheduled task), it still fails when Outlook is not already open.
Your best bet, if you have the capability, is to leave Outlook open on the machine that runs the scheduled task. Otherwise you have to try to figure out what combination of policies and registry/outlook settings will make Outlook work the way you want it to.
Edit: My experience is with a windows domain/local exchange server environment.
We upgraded to Office 2016 a few weeks ago, and had been facing the same problem as you. Our batch file runs Access and triggers a macro that exports some data to a text file, and works fine when run manually. However, when run through Task Scheduler, everything seemed to run fine, but the text file was never updated. After trying for weeks with no success, I finally found the reason for the problem, and a solution.
In our case, the problem was that Access 2016 wants to be run as a foreground app. But when running as a Task Scheduler app (with the "run whether user is logged on or not" option checked), it views itself as a background app and therefore won't run. See Jim Dettman's answers here for a bit more on that: https://www.experts-exchange.com/questions/28988837/
Next, I found this post by Microsoft employee Blake Morrison where he discusses the changes in the latest version of Task Scheduler. One of his troubleshooting suggestions worked for us:
Try creating a new task, but select the Configure for: option to be
“Windows Server 2003, Windows XP, or Windows 2000” – this will create
an XP/2003 fashioned task
Unfortunately you probably have to do this as a new task - existing tasks don't seem to allow you to choose this option (it didn't show up in the dropdown menu for my existing task). So my settings for the new task are:
Running as an administrator account
"Run whether user is logged on or not" - checked
"Run with highest privileges" - checked
Configure For: Windows Server 2003, Windows XP, or Windows 2000
If I manually trigger the task, I see a command prompt open, then Access briefly opens and disappears (our macro has a Quit Access command at the end), and then the command prompt disappears. Output to our text file is written as expected. If I schedule it to run while I'm logged out of the machine, obviously I see nothing, but the text file is again written as expected, so I know it worked.

Putty is not running using schedule task

I am using Putty to transfer files from my windows machine to Linux machine.
I am able to transfer, when i run the script and also if i run the same script using Schedule task with my credentials.
if schedule the task to run using system account(SYSTEM) or other user account, file transfer not happening.
Do i need to save any session vales?
PuTTY saves session information in the registry for the current user only, this information will simply be not available for the other accounts you mentioned. So you either need to provide them by exporting yours and importing them in the other user's accounts or simply provide everything needed on the shell command invoked to copy your files. The latter sounds much easier to me in combination with a little script which gets invoked by the task scheduler.

Opening Interactive PowerShell GUI script for other logged on users

Hello Folks,
I have a powershell MTA (GUI script using winForms), which works well, lets take the script name to be "ENDUserMTA.ps1" which does invoke certain commands and does something which really needs admin rights. this works fine when run manually or via task scheduler or when set via [registry] RunOnce or Run or whatever when there is admin rights..
The problem is i want to invoke this script on the END users laptop and make them to work with it [interactively]
Options that i have tried so far:
Tried Scheduling the "ENDUserMTA.ps1" in Task Manager SYSTEM account [using When running the task, use the following user account] - this starts and run NOT INTERACTIVE [since system account does not have interactive session]
Tried Scheduling the "ENDUserMTA.ps1" in Task Manager with Different user account which has admin rights [using When running the task, use the following user account] - This again starts but the GUI is not shown to the End User who has logged without admin rights, rather shown to only the user who was set under the option [When running the task, use the following user account]
My situation is not possible to create PSSessions or Delegated Remoting. I am now is middle of forest and no where to go!!!
Not sure how to invoke the script as admin to a user who has logged into a machine without admin rights..
WHat i exactly need or similar solution: When scheduling this script, i schedule the script to start atlogon[any user], after the script completes it will delete the scheduled task
Pls help..
Balaji
Begining on Vista Microsoft has started to separate UI stacks for security reasons.
My advise for your problem is to change the architecture of your code in order to create two scripts.
The first one with no UI will be scheduled with administrative rights
The second one with UI will be started with the user rights and will be a client of the first one.
You can use Inter-Process Communication between the two scripts, but you will met a security issue, you server part vill need particular ACLs to allow the client part to connect.
It exists other way to communicate between scripts, but it's not so easy with an asynchronous UI architecture on one side. It would be simple using managed code (.NET code) or native code(unmanaged code). For me, you are on the limit of the scripting place even if scripting capacities are very large as far as PowerShell is built on the top of .NET.

conditionally sending cron job emails

I'm not even sure if what I want is possible, but I'd like to run a Cron job where an email is only sent in certain conditions. I know that you can prevent mail from being sent at all by setting MAILTO to an empty string in the crontab file, but I've searched in several different ways, and can't find anything about sending email conditionally. My end goal is to run a Cron job that periodically checks whether the webserver is running, and if not, restart it. I only want an email if the webserver has to be restarted. I'm writing my Cron jobs in Perl. Is there a Perl command I can use within the job script that will disable the email in certain cases? Thanks for any help you can give me.
Cronjobs will send emails if the command you are running generate output. If you write your script to only send output to STDERR/STDOUT when you want an email, that should accomplish your goal.
There are 2 possibilities to send mails from cron jobs:
From program, that has been started by cron daemon,
From UNIX/Linux mechanism, that can send mail, if a program, that has been started as a cron job, has written something to STDOUT or STDERR.
I don't recommend to use the 2nd possibility. It is inflexible. You can't send mails to different recipients, depending on what alert has happened.
Usage of the 2nd way is rather a bad design. Cron jobs should redirect all their stdout and stderr to an idividual for every cron job log file for possible troubleshooting.
Perl possesses perfect possibilities to send mails, e.g. using MIME::Lite module.
This module is not a core one, so that you might should request sysadmin to install this module, if it's not available.
If you will use the 1st way, then your issue is easy to solve using Perl logic: just send the required mail from your Perl program after this program restarted the web server.