Option Explicit
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'日報を送るときの時間別件名チェックサンプル
'(ThisOutlookSession)
'メモメモφ(・ω・*)
'---------------------------------------------
'朝
If InStr(Item.Subject, "【○○】") > 0 _
And TimeValue(Now) >= TimeValue("8:30") _
And TimeValue(Now) <= TimeValue("9:30") Then
If InStr(Item.Subject, "開始") > 0 Then
'問題なければ送信
Exit Sub
Else
MsgBox "件名が違っています。もう一度確認をお願いします。", vbCritical
Cancel = True
Exit Sub
End If
End If
'---------------------------------------------
'昼
If InStr(Item.Subject, "【○○】") > 0 _
And TimeValue(Now) >= TimeValue("8:30") _
And TimeValue(Now) <= TimeValue("9:30") Then
If InStr(Item.Subject, "開始") > 0 Then
'問題なければ送信
Exit Sub
Else
MsgBox "件名が違っています。もう一度確認をお願いします。", vbCritical
Cancel = True
Exit Sub
End If
End If
'---------------------------------------------
'退社
If InStr(Item.Subject, "【○○】") > 0 _
And TimeValue(Now) >= TimeValue("8:30") _
And TimeValue(Now) <= TimeValue("9:30") Then
If InStr(Item.Subject, "開始") > 0 Then
'問題なければ送信
Exit Sub
Else
MsgBox "件名が違っています。もう一度確認をお願いします。", vbCritical
Cancel = True
Exit Sub
End If
End If
End Sub
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme