![]() |
中国DOS联盟-- 联合DOS 推动DOS 发展DOS --联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum |
| 游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟 |
|
中国DOS联盟论坛 现在时间是 2026-08-09 15:37 |
共 47,811 主题排行 / 349,896 发帖 / 今日 1 篇 / 48,254 会员排行 |
| DOS批处理 & 脚本技术(批处理室) » BAT文件收发邮件!!!?? |
| 可打印版本 833 / 2 |
| 第1楼 uforange | 发表于 2008-09-04 00:29 |
| 中级用户 发帖 92 积分 265 来自 广西 | |
|
BAT文件收发邮件!!!?? 你好!
我在论坛里搜索关于收发邮件的问题。看了好几天。也实验了好几天可是做不了。认真看时看到一个for。。。后面一大堆好东东时又看不懂。。。没有办法。。 请知道的朋友多点耐心再次帮说清楚和具体点和简单一点。在此就谢谢了。。 我的问题是这样的: 我想做一个BAT文件打开时就可以将我本地d:\orange.txt 做为附件 在本地用 hh163@163.com 密码为: asdf123 发送到 orange163163@163.com 里面 或者能有什么好的方法把d:\orange.txt发送到orange163163@163.com里面 最好是打开就可以完成的不再用人工了的。。。再次谢谢。。。 [ Last edited by uforange on 2008-9-4 at 12:45 AM ] |
|
| 第2楼 HAT | 发表于 2008-09-04 09:53 |
| 版主 发帖 5,017 积分 9,023 | |
| 第3楼 uiopuiop | 发表于 2008-09-04 10:05 |
| 中级用户 发帖 211 积分 400 | |
|
sendmail.vbs 'Comment envoyer un email en VBScript (SENDMAIL.VBS)
Option explicit On error resume next Const ProgVersion="3.0" Dim WshArgs, WshNetwork Dim iMsg, Flds, iConf Dim i, j, sKey, sVal Dim sFrom, sTo, sCC, sBCC, sSubject, sBody, sServer, iPort, sUserName, sPassword, sAttach() Set WshArgs = WScript.Arguments Set WshNetwork = WScript.CreateObject("WScript.Network") 'DEFAULT VALUES IF NONE GIVEN sFrom = WshNetwork.ComputerName sServer = "ROP-MES01" iPort = 25 Rem AUTEUR: uiopuiop Rem ------------------------------------------------------------------------ redim preserve sAttach(0) for i=0 to WshArgs.Count - 1 GetVal WshArgs(i), sKey, sVal 'On split les arguments wscript.echo "<" & sKey & "> = <" & sVal & ">" Select case Ucase(sKey) case "FROM": sFrom=sVal case "TO": sTo=sVal case "CC": sCC=sVal case "BCC": sBCC=sVal case "SUBJECT": sSubject=sVal case "BODY": sBody=sVal case "SERVER": sCC=sVal case "PORT": iPort=sVal case "USERNAME": sUserName=sVal case "PASSWORD": sPassword=sVal case "ATTACH" j=uBound(sAttach):redim preserve sAttach(j+1) sAttach(j)= sVal ' wscript.echo "Dim:" & j & " Attach:" & sAttach(j) end select next Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields ' Set oRec = CreateObject("ADODB.Record") ' Set Conn = CreateObject("ADODB.Connection") Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sServer Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = iPort Flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = sUserName Flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPassword Flds.Update With iMsg Set .Configuration = iConf if uBound(sAttach)>0 then for i=0 to uBound(sAttach) - 1 .AddAttachment sAttach(i) next end if .From = sFrom .To = sTo .Cc = sCC .bcc = sBcc .Subject = sSubject .TextBody = sBody .Send End With if err.number <> 0 then wscript.echo "ERREUR: " & vbCrLf & vbCrLf & _ ShowSyntax() else wscript.echo "Mail sent successfully at " & Now end if wscript.quit 'Splitter une chaine en 2 Sub GetVal( sLigne, byRef sKey, byRef sVal) Dim iPos iPos=InStr(sLigne,"=") if iPos>0 then sKey=ucase(Left(sLigne,iPos-1)) if len(sLigne)>iPos then sVal=Trim(Mid(sLigne,iPos+1,len(sLigne)-iPos)) else sVal="" end if else sKey="" sVal="" end if ' wscript.echo "Ligne:" & sLigne & " sKey=" & sKey & " sVal=" & sVal end Sub function ShowSyntax Dim sOut sOut = "" sOut = sOut & "SYNTAXE: cscript " & wscript.Scriptname & " ARGUMENTS" & vbcrlf & vbCrLf sOut = sOut & "From=<Email of sender>. Default is servername." & vbCrLf sOut = sOut & "To=<Emails of recipients separated by ;>. The only mandatory parameter." & vbCrLf sOut = sOut & "CC=<Emails of Carbon Copy separated by ;>" & vbCrLf sOut = sOut & "BCC=<Emails of Blind Carbon Copy separated by ;>" & vbCrLf sOut = sOut & "Subject=<Mail subject>" & vbCrLf sOut = sOut & "Body=<Text body of email>" & vbCrLf sOut = sOut & "Server=<Host name of SMTP server>. Default is " & sServer & "." & vbCrLf sOut = sOut & "Port=<Port number of SMTP server>. Default is 25." & vbCrLf sOut = sOut & "Username=<Username of non anonymous SMTP connection>" & vbCrLf sOut = sOut & "Username=<Password of non anonymous SMTP connection>" & vbCrLf sOut = sOut & "Attach=<Path of attachment>. Many attachments may be given" & vbCrLf & vbCrLf sOut = sOut & "If arguments contain spaces, you must quote arguments" & vbCrLf sOut = sOut & "cscript sendmail.vbs TO=user1@mycorp.com;user2@yours.com " & chr(34) & "subject=Subject with spaces" & chr(34) & " Attach=c:\myfile1.txt " & chr(34) & "Attach=d:\my file2.txt" & chr(34) & vbCrLf ShowSyntax = sOut end function |
|
|
[ 联系联盟系统管理团队 -
中国DOS联盟 -
标准版 ] Sponsored by ifanr Inc | © 2001–2023 |