-
Notifications
You must be signed in to change notification settings - Fork 0
/
InsertMemo.vb
57 lines (43 loc) · 1.68 KB
/
InsertMemo.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Sub InsertMemo()
' Open HTML file
Dim MemoHTMLFile As String, text As String, textline As String
MemoHTMLFile = "C:\Users\HartmRob\Macros\Memo.html"
Open MemoHTMLFile For Input As #1
Dim MemoHTML As String
Do Until EOF(1)
Line Input #1, textline
MemoHTML = MemoHTML & textline
Loop
Close #1
' Retrieve mail item
Dim CurrentMail As MailItem, oInspector As Inspector
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
MsgBox "No active inspector"
Else
Set CurrentMail = oInspector.CurrentItem
If CurrentMail.Sent Then
MsgBox "This is not an editable email"
Else
CurrentMail.Save
' Get current date
Dim CurrentDate As String
CurrentDate = FormatDateTime(Date, vbShortDate)
' Fill in placeholders
Dim Subject As String
Subject = CurrentMail.Subject
MemoHTML = Replace(MemoHTML, "%DATE%", CurrentDate)
MemoHTML = Replace(MemoHTML, "%SUBJECT%", Subject)
' Add items to mail item
CurrentMail.Subject = "[Memo " & CurrentDate & "] " & CurrentMail.Subject
CurrentMail.Save
CurrentMail.BodyFormat = olFormatHTML
CurrentMail.HTMLBody = MemoHTML & CurrentMail.HTMLBody
End If
End If
End Sub
Public Sub CategoriesButton()
Dim Item As Outlook.MailItem
Set Item = Application.ActiveInspector.CurrentItem
Item.ShowCategoriesDialog
End Sub