--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
――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.
--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