中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » BAT文件收发邮件!!!??
作者:
标题: BAT文件收发邮件!!!?? 上一主题 | 下一主题
uforange
中级用户





积分 265
发帖 92
注册 2006-11-29
来自 广西
状态 离线
『楼 主』:  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 ]


2008-9-4 00:29
查看资料  发送邮件  访问主页  发短消息 网志  OICQ (690660564)  编辑帖子  回复  引用回复
HAT
版主





积分 9023
发帖 5017
注册 2007-5-31
状态 离线
『第 2 楼』:  

这个不行吗? p-mailsend_4.0.cmd(命令行发送邮件,群发\多附件\匿名) www.cn-dos.net/forum ...




2008-9-4 09:53
查看资料  发短消息 网志   编辑帖子  回复  引用回复
uiopuiop
中级用户





积分 400
发帖 211
注册 2007-9-30
状态 离线
『第 3 楼』:  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: [Number=" & err.number & "][Description=" & err.description & "]" & 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


   此帖被 +1 点积分     点击查看详情   
评分人:【 uforange 分数: +1  时间:2008-9-5 03:07


2008-9-4 10:05
查看资料  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: