-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewvbs.vbs
64 lines (62 loc) · 3 KB
/
newvbs.vbs
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
58
59
60
61
62
63
64
strAttachment = "C:\Batch File Test\systems_status.txt"
strAttachment2 = "C:\Batch File Test\links_status.txt"
strMailFile = 2
sendMail "[email protected]", _
"[email protected]", _
"Batch File Automation Test", _
"This is a test of the Batch Files Automation process."
'#-------------------------------------------------------------------------
'# FUNCTION.......: sendMail(strFrom, strTo, strSubject, strMail)
'# ARGUMENTS......: strFrom - Email Sender
'# strTo - Email recipient
'# strSubject - Email subject
'# strMail - Email body
'# PURPOSE........: Sends email from a script
'# EXAMPLE........: sendMail "[email protected]", _
'# "[email protected]", _
'# "sendMail Function Test", _
'# "This is a test of the sendMail Function."
'#
'# NOTES..........: For this to work, you must define the variable
'# "oMailServer" on line 1 of the actual Function. This
'# must be set to a valid email server that will accept
'# unauthenticated email from your machine (if you host
'# Exchange onsite, it will do this by default).
'#
'# To add an attachment add this code above the Function
'# call:
'# strAttachment = "c:\yourAttachment.txt"
'# strMailFile = 1
'#
'# If there are two attachemnts, add this code before
'# the Function call:
'# strAttachment = "c:\yourAttachment.txt"
'# strAttachment2 = "c:\yourAttachment2.txt"
'# strMailFile = 2
'#
'#-------------------------------------------------------------------------
Function sendMail(strFrom, strTo, strSubject, strMail)
oMailServer = "10.30.24.65"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSubject
objEmail.Textbody = strMail
If strMailFile = 1 Then
objEmail.AddAttachment strAttachment
End If
If strMailFile = 2 Then
objEmail.AddAttachment strAttachment
objEmail.AddAttachment strAttachment2
End If
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
oMailServer
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
= 25
objEmail.Configuration.Fields.Update
objEmail.Send
End Function