[VBS] 이메일 보내기

5183 단어 vbs
 1 Sub SendMail(pMailFrom, pMailTo, pSubject, pMailBody, pMailSmtpServer)
 2   On Error Resume Next
 3   Dim objShell
 4   Dim oMsg
 5 
 6   Set objShell = CreateObject("Wscript.Shell")
 7   Set oMsg = CreateObject("CDO.Message")
 8 
 9   oMsg.From = pMailFrom & " <" & pMailFrom & ">"  ' 
10   oMsg.To = pMailTo & " <" & pMailTo & ">"        ' 
11   oMsg.Subject = pSubject                         ' 
12   oMsg.HtmlBody = pMailBody                       ' (HTML )
13   'oMsg.TextBody = pMailBody                       ' ( )
14 
15   oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
16   oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = pMailSmtpServer 'ExChange 
17   oMsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
18   oMsg.Configuration.Fields.Update
19 
20   oMsg.Send
21   If Err.Number <> 0 Then
22     AddLog ("" & Err.Description)
23     WScript.Quit -1
24   End If
25   
26   Set oMsg = Nothing
27   Set objShell = Nothing
28 End Sub

좋은 웹페이지 즐겨찾기