Task registration or Notification in Python in Outlook (from VIM)

For those who have a tight internal proxy and can only use Outlook

The task function of Outlook is insanely amazing

--Todoixx, Wundexxx-Before you say, can you use Outlook? --Anyway, the company forces Outlook, right? !! --Outlook task registration is extremely sophisticated! ――It's amazing, but registration is troublesome and no one is using it

Take advantage of the lightness of Python

――If you make a source with Python, you can cooperate in various ways and you are free depending on your ideas --Can also be used like Notification --You can set the deadline and Post (although you can set the deadline manually)

Vimmer? --You can call Python from Vim and register Task in Outlook. --You can do it by running Python, even if it's not Vim.

In this example, Vim is used as an interface to flow tasks.

--Write something in Vim -[: PostOutlookTask] Then, the text you are writing will be registered in the Outlook Task. --If you put Path in filename, you can execute it with Python alone.

win32com.client --Prepare win32com.client to operate Outlook --If you are in Anaconda environment, it is included by default, so it's okay death

Source

Outlook_alert_vim.py


# coding: utf-8
import pytz
import sys
from datetime import datetime, timedelta
import win32com.client as wcl


def win_time_norm(d):
    '''
Convert to Outlook Time Format
    :param d: Datetime
    :return: Type pytx Datetime
    '''
    date = pytz.utc.localize(d)
    return date


def post_outlook_task(task_list):
    '''
Register a task in Outlook
・ Win32com.Preparing the client
・ If it is Anaconda, it is included by default.
    out_task.DueDate = s_win_day
・ If you set the date to today, Notification can be used instead.
・ If the deadline is set, e_win_Register day
・ Edday(5 days)で5 days後アラートにしてる
    :param task_list:Subject the first line of Text in VIM
    '''
    stday = datetime.today()
    edday = datetime.today() + timedelta(days=5)
    s_win_day = win_time_norm(stday)
    e_win_day = win_time_norm(edday)

    outlook = wcl.Dispatch("Outlook.Application")
    for task in task_list:
        out_task = outlook.CreateItem(3)
        out_task.Subject = task[0]
        out_task.Body = task[1]
        out_task.StartDate = s_win_day
        out_task.DueDate = s_win_day
        # out_task.DueDate = e_win_day
        out_task.ReminderSet = True
        out_task.Save()


def main(args):
    filename = str(args[0])
    with open(filename, mode="r", encoding='utf-8') as fh:
        data = fh.readlines()

    data = [t.strip().strip('\n') for t in data if t]
    #I am able to register continuously(I don't need this example)
    task_list = []
    task_list.append((data[0], "\n".join(data)))
    # task_list.append(("test subject","body row1 \n body row2"))

    post_outlook_task(task_list)


if __name__ == "__main__":
    main(sys.argv[1:])

Specify the location of s: python_file yourself.

_vimrc


"outlook_task_vim"{{{
function! s:outlook_posttask_vim()"
    let s:python_file = "D:/Outlook_alert_vim.py"
    let s:file = tempname()
    silent execute ":write " . s:file
    silent execute "!python " . s:python_file . ' ' . s:file
    call delete(s:file)
    unlet! s:file
    unlet! s:py_script
endfunction augroup END"
command! -nargs=0 PostOutlookTask call s:outlook_posttask_vim()
"}}}

Recommended Posts

Task registration or Notification in Python in Outlook (from VIM)
Python from or import
OCR from PDF in Python
Read Outlook emails in Python
Get data from Quandl in Python
Error notification method when calling python from windows GUI or winsound.Beep
Automatically format Python code in Vim
Extract text from images in Python
Write a vim plugin in Python
I tried Line notification in Python
Extract strings from files in Python
A story about a beginner making a VTuber notification bot from scratch in Python
Get exchange rates from open exchange rates in Python
Revived from "no internet access" in Python
Prevent double boot from cron in Python
Express Python yield in JavaScript or Java
OR the List in Python (zip function)
Push notification from Python server to Android
Referencing INI files in Python or Ruby
Download images from URL list in Python
Get battery level from SwitchBot in Python
Write a simple Vim Plugin in Python 3
Generate a class from a string in Python
Non-logical operator usage of or in python
Generate C language from S-expressions in Python
Convert from Markdown to HTML in Python
Get Precipitation Probability from XML in Python
Parallel task execution using concurrent.futures in Python
Get metric history from MLflow in Python
Create a Vim + Python test environment in 1 minute
[Python] Convert from DICOM to PNG or CSV
From file to graph drawing in Python. Elementary elementary
Create a New Todoist Task from Python Script
Use Python in your environment from Win Automation
Use emacs or vim keybindings in IPython notebook
Let's make some notification processing samples in Python
Split files when writing vim plugin in python
Call a Python script from Embedded Python in C ++ / C ++
Load images from URLs using Pillow in Python 3
Randomly select elements from list (array) in python
Get only articles from web pages in Python