문제

Windows Server 2003 Standard Edition의 스크립트에서 메일을 보내고 싶습니다. 서버 설정이 거의 상자에서 벗어 났다고 생각합니다.

메일 서버는 교환 서버이며 내부 네트워크에있을 때는 일반 기존 SMTP를 사용할 수 있습니다. Perl이있는 컴퓨터에서 수행했지만 불행히도 Perl은 서버에서 사용할 수 없습니다.

.bat-file 또는 추가 소프트웨어를 설치할 필요가없는 다른 방법에서 쉽게 수행 할 수있는 방법이 있습니까?

Edit:
빠른 답변에 감사드립니다. "blat"the the the the는 아마도 잘 작동하지만 wscript를 사용하면 별도의 이진을 사용할 필요가 없습니다.

처음 편집하고 답을 선택한 Philho의 게시물을 보지 못했습니다. 여기에서 코드를 복제 할 필요가 없습니다.

스크립트를 파일에 저장하고 sendmail.vbs를 말한 다음, 다음과 같은 명령 프롬프트에서 호출하십시오.
wscript sendmail.vbs

도움이 되었습니까?

해결책

CDO를 사용하여 WSCRIPT를 사용하면 가능합니다.

Dim objMail

Set objMail = CreateObject("CDO.Message")

objMail.From = "Me <Me@Server.com>"
objMail.To = "You <You@AnotherServer.com>"
objMail.Subject = "That's a mail"
objMail.Textbody = "Hello World"
objMail.AddAttachment "C:\someFile.ext"

---8<----- You don't need this part if you have an active Outlook [Express] account -----
' Use an SMTP server
objMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

' Name or IP of Remote SMTP Server
objMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
    "smtp.server.com"

' Server port (typically 25)
objMail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMail.Configuration.Fields.Update
----- End of SMTP usage ----->8---

objMail.Send

Set objMail=Nothing
Wscript.Quit

업데이트 : 추가 정보를 찾았습니다. CDO를 사용하여 이메일을 보내는 vbscript기본적으로 Outlook [Express]를 사용하는 것처럼 보이므로 내 컴퓨터에서 작동하지 않았지만 주어진 SMTP 서버를 사용할 수 있습니다.

다른 팁

.BAT 파일과 함께 바이너리를 삭제하는 것이 소프트웨어 설치로 계산되는지 모르겠지만 그렇지 않은 경우 사용할 수 있습니다. 블래트 이것을하기 위해.

PowerShell V2를 설치 한 서버가 발생한 경우 (이 질문이 몇 살인지 알고 있습니다) CMDLET Send-MailMessage는 한 줄로이를 수행합니다.

Send-MailMessage [-To] <string[]> [-Subject] <string> -From <string> [[-Body] <string>] [[-SmtpServer] <string>] [-Attachments <string[]>] [-Bcc <string[]>] [-BodyAsHtml] [-Cc <string[]>] [-Credential <PSCredential>] [-DeliveryNotficationOption {None | OnSuccess | OnFailure | Delay | Never}] [-Encoding <Encoding>] [-Priority {Normal | Low | High}] [-UseSsl] [<CommonParameters>]

Outlook/Exchange가 설치된 경우 CDONTS를 사용할 수 있어야합니다. Mail.VBS 파일 만 만들어 배치 파일로 호출하십시오 (재미있는 딥에 재미 있음).

wscript mail.vbs

vbscript 코드의 경우 확인하십시오

http://support.microsoft.com/kb/197920

http://www.w3schools.com/asp/asp_send_email.asp

두 링크가 ASP에 대해 말하는 사실을 잊어 버리십시오. IIS가있는 독립형 스크립트로 잘 작동해야합니다.

wscript에서 호출 할 수있는 일부 ActiveX 또는 다른 구성 요소를 설치해야한다고 생각합니다.http://www.activexperts.com/activemail/그리고:http://www.emailarchitect.net/webapp/smtpcom/developers/scripting.asp

그렇지 않으면, 전체 SMTP 로직 (가능하면 확실하지 않은 경우)을 직접 작성해야합니다.

Windows 스크립팅 호스트 (wscript)와 함께 CDONTS 사용

Is there a way you send without referencing the outside schema urls. http://schemas.microsoft.com/cdo/configuration/

That is highly useless as it can't be assumed all boxes will have outside internet access to send mail internally on the local exchange. Is there a way to save the info from those urls locally?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top