Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7913045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:45:05+00:00 2026-06-03T13:45:05+00:00

I created a shutdown.py script that shuts down my computer. I have a working

  • 0

I created a shutdown.py script that shuts down my computer.
I have a working rule in Microsoft Outlook that executes my Python script when I receive an email that has %BLAHBLAHBLAH% in the subject.

Is it possible to pass the email’s subject line into the Python script before executing it?
Basically, I want a keyword in the subject line to execute a certain script but also be able to "pass" parameters into the email’s subject line to the Python script.
For example if I send %shutdown30% my python script would parse the string %shutdown30% and use the 30 as a parameter to shutdown the computer in 30 minutes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:45:07+00:00Added an answer on June 3, 2026 at 1:45 pm

    Why creating a rule in outlook that runs a script if an email is received, when you can simply do it all from python.

    Using Python to monitor outlook for all incoming emails and then execute some code if an email, with %BLAHBLAH% in the subject, is received is possible. Here is an example:

    import win32com.client
    import pythoncom
    import re
    
    class Handler_Class(object):
        def OnNewMailEx(self, receivedItemsIDs):
            # RecrivedItemIDs is a collection of mail IDs separated by a ",".
            # You know, sometimes more than 1 mail is received at the same moment.
            for ID in receivedItemsIDs.split(","):
                mail = outlook.Session.GetItemFromID(ID)
                subject = mail.Subject
                try:
                    # Taking all the "BLAHBLAH" which is enclosed by two "%". 
                    command = re.search(r"%(.*?)%", subject).group(1)
    
                    print command # Or whatever code you wish to execute.
                except:
                    pass
    
    
    outlook = win32com.client.DispatchWithEvents("Outlook.Application", Handler_Class)
    
    #and then an infinit loop that waits from events.
    pythoncom.PumpMessages() 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up a Python script that simulates an OS. It has a
I want to create a process which uses shutdown.exe to shut down the computer
I'm trying to make a batch file that executes a simple command: shutdown -h
I have installed Jenkins 1.452 as a Windows service and created a job that
I have created an upstart script in order to daemonize juggernaut (a node.js app)
I've created a simple test app (Python 2.6.1) that runs a ThreadingTCPServer, based on
I have created a WCF method that runs an infinite loop, polling every 5
I created a JApplet using Netbeans 6.5.1 that accesses a database. When the program
I have this piece of code where a server socket is created and is
I have inherited a 20-year-old interactive command-line unix application that is no longer supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.