vbscript VBSCRIPT_EMAIL
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript VBSCRIPT_EMAIL相关的知识,希望对你有一定的参考价值。
on error resume next
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 2
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Dim sDateTimeStamp
Dim abData
Set args = WScript.Arguments
' arg1 = args.Item(0) 'the parameter from batch comes in here to arg1
' arg2 = args.Item(1) 'the parameter from batch comes in here to arg1
' arg3 = args.Item(2) 'the parameter from batch comes in here to arg1
arg1 = args(0)
arg2 = args(1)
arg3 = args(2)
arg4 = args(3)
' Doesnt work - lines are not added Newlinetried, vbcrlf tried, vbCr tried
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "k.athanasopoulos@dei.com.gr" ' or "Sender Name <from@gmail.com>"
oMsg.To = "p.doulgeridis@dei.com.gr,k.athanasopoulos@dei.com.gr" ' or "Recipient Name <to@gmail.com>"
oMsg.CC = "p.doulgeridis@dei.com.gr"
oMsg.Subject = "System Backup Notification - File Transfer. (TRANSMETAV)"
'oMsg.BodyPart.Charset = "iso-8859-7"
oMsg.BodyPart.Charset = "Windows-1253"
' GREEK WORKS
'oMsg.TextBody = "Transfer of files failed - ΛΟΓΑΡΙΑΣΜΟΙ Check RUNLOG for error. Julian date : " & arg1 & multi
oMsg.HTMLBody = "<b><font size=3 color=red> BATCH JOB MPATI FAILED : <br><font color=black> TRANSFER OF FILES FAILED </font></font><br> CHECK RUNLOG FOR ERRORS.</b>" & arg1 & "<br>Importance: " & arg3 & "<br>Type: " & arg2 & "<br> Section: " & arg4
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "holhub.intranet.dei.com.gr" 'server address
oConf.Fields(schema & "smtpserverport") = 587 'port number
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic 'authentication type
oConf.Fields(schema & "smtpusessl") = False 'use SSL encryption
oConf.Fields(schema & "sendusername") = "k.athanasopoulos@intranet.dei.com.gr" 'sender username
oConf.Fields(schema & "sendpassword") = "Patra2016" 'sender password
oConf.Fields.Update()
'base64
' send message
oMsg.Send()
' Return status message
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Error Notification Message sent succesfully."
End If
Wscript.echo(resultMessage)
on error resume next
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Dim sDateTimeStamp
' E-mail properties
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "PanagosPC@gmail.com" ' or "Sender Name <from@gmail.com>"
oMsg.To = "panosdoulgeridis@gmail.com" ' or "Recipient Name <to@gmail.com>"
oMsg.Subject = "System Backup Notification from HOME - PC."
oMsg.TextBody = "System backup performed succesfully. "
' GMail SMTP server configuration and authentication info
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com" 'server address
oConf.Fields(schema & "smtpserverport") = 465 'port number
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic 'authentication type
oConf.Fields(schema & "smtpusessl") = True 'use SSL encryption
oConf.Fields(schema & "sendusername") = "pdoulge@gmail.com" 'sender username
oConf.Fields(schema & "sendpassword") = "panagos69" 'sender password
oConf.Fields.Update()
' send message
oMsg.Send()
' Return status message
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Message sent ok"
End If
Wscript.echo(resultMessage)
以上是关于vbscript VBSCRIPT_EMAIL的主要内容,如果未能解决你的问题,请参考以下文章