2013-12-14 5 views
-1

배치를 사용하여 프로그램을 만들고 있는데 충돌 또는 오류 발생시 debug.txt이라는 텍스트 파일을 만듭니다. 나는이 파일을 자동으로 배치를 사용하여 다음 이메일 주소 "[email protected]"에 이메일로 보내는 방법이 있는지 알아야합니다. debug.txt은 배치 파일과 동일한 위치에 있습니다. 누구든지 사용할 수있는 코드를 알고 있습니까? 추가 소프트웨어가 없어야합니다.이메일 일괄 처리

1 결론이 배치에는 내장 된 방법이 없지만, 호출 할 수 있습니다 BLAT 등과 같은 타사 도구가 있습니다 :

+2

어쨌든 답변을 드릴 필요가 없으므로 내가 당신 인 경우 이메일 주소를 삭제하겠습니다. – zbr

+1

텍스트이기 때문에 메일 메시지 본문으로 이메일로 보낼 수 있습니다. 예를 들어,'sendmail [options] [email_address] lurker

+2

@Zabri가 옳습니다. 공개 포럼에 이메일을 게시해서는 안됩니다. 그것은 스팸 메일을 많이받는 주요 방법입니다. – lurker

답변

1

는 지금의 당신을위한 3 개 가지 옵션 참조 배치 파일에서 가져 왔지만, 언급 한대로 추가 소프트웨어는 필요하지 않습니다.

2. Windows의 설치된 SMTP 서버를 활성화 할 수 있습니다. 그리고 다음 PowerShell 스크립트를 실행

$smtpServer = "system.abc.com" 
$smtpFrom = "[email protected]" 
$smtpTo = "[email protected]" 
$messageSubject = "Put your subject here" 

$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto 
$message.Subject = $messageSubject 
$message.IsBodyHTML = $true 
$message.Body = Get-Content debug.txt 

$smtp = New-Object Net.Mail.SmtpClient($smtpServer) 
$smtp.Send($message) 

3. 당신은 윈도우의 설치 SMTP 서버를 활성화 할 수 있습니다. 그리고 다음의 VBScript를 실행

당신은 당신이 그렇게 모두 옵션 2와 3은 매우 당신의 시스템에서 작동 궁극적 인 윈도우 7을 사용하고 있다고 언급 한 것처럼
Const ForReading = 1 
Const ForWriting = 2 
Const ForAppending = 8 
Const FileToBeUsed = "debug.txt" 
Dim objCDO1 
Dim fso, f 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set f = fso.OpenTextFile(FileToBeUsed, ForReading) 
Set objCDO1 = CreateObject("CDO.Message") 
objCDO1.Textbody = f.ReadAll 
f.Close 
objCDO1.TO ="[email protected]" 
objCDO1.From = "[email protected]" 
objCDO1.Subject = "Put your subject here" 
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /sendusing") = 2 
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /smtpserver") = "system.abc.com" 
objCDO1.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration /smtpserverport") = 25 
objCDO1.Configuration.Fields.Update  
objCDO1.Send 
Set f = Nothing 
Set fso = Nothing 

.

0

sendemail.exe http://caspian.dotconf.net/menu/Software/SendEmail/과 같은 무료 도구를 사용할 수 있습니다. sendemail.exe를 다운로드하여 시스템 경로에 복사하십시오. 이는 단순한 내부 SMTP 메시지에만 해당됩니다. Exchange 서버가 익명의 외부 메시지를 보내도록 설정되어 있지 않으면 외부 메시지를 보내는 데 사용할 수 없습니다. 거의 모든 Exchange 서버가이를 수행하도록 설정되어 있지 않습니다.

배치 스크립트에서이 간단한 루틴을 사용할 수 있습니다.

CALL:SENDEMAILALERT "From SMTP address" "To SMTP addresses" "Subject" "Message" "File to attach" "smtp.host.com:25" 

:SENDEMAILALERT 
SET SENDEMAILCMD=-f "%~1" 
SET SENDEMAILCMD=%SENDEMAILCMD% -t "%~2" 
SET SENDEMAILCMD=%SENDEMAILCMD% -u "%~3" 
SET SENDEMAILCMD=%SENDEMAILCMD% -m "%~4" 
SET SENDEMAILCMD=%SENDEMAILCMD% -a "%~5" 
SET SENDEMAILCMD=%SENDEMAILCMD% -s "%~6" 
SENDEMAIL %SENDEMAILCMD% >NUL 2>&1 
SET SENDEMAILCMD= 
GOTO:EOF 
+0

내가 질문에서 말했듯이 나는 여분의 소프트웨어를 포함하지 말아야한다. – 09stephenb