LoginSignup
3
3

More than 3 years have passed since last update.

outlookメールで自動メッセージbotを作る

Last updated at Posted at 2020-05-10

outlookを使っている人向けに、自分のPCのメールからスクリプトを使ってメール送信する方法を紹介

フォルダ内

image.png

'01.vbsの中身

Set olkApp = CreateObject("Outlook.Application")
Set objMsg = olkApp.CreateItem(0) ' 0 = olMailItem
objMsg.To = "送り先@gmail.com"
objMsg.Subject = "this is subject"
objMsg.Body = "hi, this mail is automatic by bat"
objMsg.Send 
#01.batの中身

@echo off

cscript 01.vbs

pause

同じフォルダの中にファイルを入れておけば添付もできる

'01.vbsの中身

Set olkApp = CreateObject("Outlook.Application")
Set objMsg = olkApp.CreateItem(0) ' 0 = olMailItem
objMsg.To = "送り先@gmail.com"
objMsg.Subject = "this is subject"
objMsg.Body = "hi, this mail is automatic by bat"
objMsg.Attachments.Add "C:\users\desktop\outlook_auto_mail\tenpu.pdf"
objMsg.Send 

あとはタスクスケジューラーでbatファイルを定期的にたたく

例えばRやpythonの分析を定期的に行って、出力したファイルをメールで送る
なんて使い方もできます。

#01.batの中身

@echo off

rscript 01.r
python 01.py
cscript 01.vbs

pause

おわり

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3