-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathOutlook VBA - Send mail.vb
55 lines (42 loc) · 1.16 KB
/
Outlook VBA - Send mail.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
Sub add_recepient()
Dim new_Message As MailItem
Set new_Message = Application.CreateItem(olMailItem)
With new_Message
.To = "[email protected]"
.CC = "[email protected]"
.BCC = "[email protected]"
.Subject = "Google"
'.Categories = "Test"
'.VotingOptions = "Yes;No;Maybe"
.BodyFormat = olFormatHTML
.Body = "Text"
'.Importance = olImportanceHigh
'.Sensitivity = olConfidential
'.Attachments.Add "..."
'.ExpiryTime = DateAdd("m", 6, Now)
'.DeferredDeliveryTime = #8/5/2018 6:00:00 PM#
.Display
End With
Set new_Message = Nothing
End Sub
Public Sub CreateNewMessage()
'
' Sends mail to sender based on the active selection
'
Dim objMsg As MailItem
Dim Selection As Selection
Dim obj As Object
Set Selection = ActiveExplorer.Selection
For Each obj In Selection
Set objMsg = Application.CreateItem(olMailItem)
With objMsg
.To = obj.SenderEmailAddress
.Subject = "This is the subject"
.Categories = "Test"
.Body = "My notes" & vbCrLf & vbCrLf & obj.Body
.Display
' use .Send to send it automatically
End With
Set objMsg = Nothing
Next
End Sub