Windows平台 用邮件方式发送export备份情况

windows平台,对于export备份,希望能在备份结束后将出错信息发给相关人员。可以这么做:[@more@]

1.写export的bat文件:

set nls_lang=AMERICAN_AMERICA.WE8MSWIN1252
EXP username/password@service_name FILE=*.dmp LOG=*.LOG FULL=Y COMPRESS=N

type *.LOG | find "Export terminated successfully without warnings."
IF ERRORLEVEL 1 GOTO SendAlert

GOTO End

:SendAlert
cscript D:DBEXPBackupAlert.vbs

:End

2.BackupAlert.vbs:

Option Explicit

Dim objMessage, strReceiver, strSender, strSubject, strContent, strAttachment

strReceiver =" user@*.com"
strSender = "sender@*.com"
strSubject = "xxxDB Export is failed"
strContent = ""
strAttachment = "D:DBEXPExportdb.LOG"

set objMessage = CreateObject("CDO.Message")

'With objMessage

objMessage.from = strSender
objMessage.To = strReceiver

objMessage.TextBody = strContent

objMessage.Subject = strSubject

' .BodyPart.Charset="gb2312";

' .HTMLBodyPart.Charset="gb2312";

objMessage.AddAttachment strAttachment

' With .Configuration

objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort

objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail_server_ip_address"

objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.update

' End With

'End With


objMessage.send

请使用浏览器的分享功能分享到微信等