找回密码
 加入
搜索
查看: 11766|回复: 19

[系统综合] [已解决]发送邮件的UDF或脚本

 火.. [复制链接]
发表于 2011-9-27 08:05:43 | 显示全部楼层 |阅读模式
本帖最后由 fuinei 于 2011-10-10 23:36 编辑

各位好,请问如需实现ping某个IP地址不通的情况下发送邮件给某几个人可以如何实现呢?
发表于 2011-9-27 08:40:27 | 显示全部楼层
本帖最后由 zsken 于 2011-9-27 08:48 编辑
; 请先注册 jmail.dll, 最好是用JMail4.4_PRO,因为这个版本有POP3功能,方便以后收信息。
; 如果只是用来发送,其它版本都可以。
; 为了脚本的健壮性,最好处理COM错误, 如 ObjEvent("AutoIt.Error", "AutoCOMErrFunc")
; 如果测试用的也是QQ邮件请开能SMTP功能,其它如163等默认都是开通的


Local $msg = ObjCreate ("JMail.Message")
If IsObj($msg) Then
        $msg.Charset = "gb2312"
        $msg.Silent = true
        $msg.Priority = 3

        $msg.MailServerUserName = "1234567"                             ; SMTP验证用户名
        $msg.MailServerPassword = "7654321"                             ; SMTP验证密码

        $msg.From = "1234567@qq.com"                                    ; 发件人地址
        $msg.FromName = "1234567"                                       ; 发件人名称
        $msg.AddRecipient("1234567@qq.com", "1234567")                  ; 收件人信息
        $msg.Subject = "测试"                                           ; 邮件标题
        $msg.Body = "这是测试邮件" & @CRLF                              ; 邮件内容第1行
        $msg.AppendText("这是附加的信息")                               ; 邮件内容第n行

        If $msg.Send("smtp.qq.com") Then
                MsgBox(0, "", "发送成功")
        Else
                MsgBox(0, "", "发送失败")
        EndIf
Else
        MsgBox(0, "", "ObjCreate Jmail.Message失败")
EndIf

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-9-27 10:07:08 | 显示全部楼层
使用Jmail4.5free版本已测试成功,谢谢2楼的指导
请问你上传的pro版本是否是全功能的呢?官网是收费的哦
发表于 2011-9-27 10:50:38 | 显示全部楼层
楼上的支持带附件吗?
 楼主| 发表于 2011-9-27 11:33:50 | 显示全部楼层
请问zsken 兄提供的jmail4.4Pro.rar是否为全功能无限制版本呢?
发表于 2011-9-27 12:44:16 | 显示全部楼层
回复 4# menfan1


    搜索
SmtpMailer.au3

支持附件的
发表于 2011-9-27 14:13:54 | 显示全部楼层
顶六楼的,我测试过,完全可以用,不需要jmail.dll
二楼的也可以用
 楼主| 发表于 2011-9-27 15:52:28 | 显示全部楼层
Jmail.dll测试可用,官网也有example和说明文档,请问楼上的兄弟可提供一个smtpmailer.au3的使用范例吗?
发表于 2011-9-27 18:10:04 | 显示全部楼层
网上找的
;~   Smtp   Mailer

;[url]http://www.autoitscript.com/forum/index.php?showtopic=23860&st=0[/url]
#Include<file.au3>
Global   $oMyError   =   ObjEvent("AutoIt.Error",   "MyErrFunc")
;##################################
;   Include
;##################################
#Include<file.au3>
;##################################
;   Variables
;##################################
$s_SmtpServer   =   "smtp.gmail.com"    ;   smtp服务器   address   for   the   smtp-server   to   use   -   REQUIRED
$s_FromName   =   "www.yidabu.com"        ;   邮件发送人   name   from   who   the   email   was   sent
$s_FromAddress   =   "your@gmail.com" ; 邮件发送者地址address   from   where   the   mail   should   come
$s_ToAddress   =   "your@gmail.com"        ;   邮件发送给谁   destination   address   of   the   email   -   REQUIRED
$s_Subject   =   "bbs.yidabu.com"          ;邮件标题   subject   from   the   email   -   can   be   anything   you   want   it   to   be
$as_Body   =   "autoit论坛"   &   @CRLF   &   _
"http://bbs.yidabu.com/forum-2-1.html"    ;   邮件正文the   messagebody   from   the   mail   -   can   be   left   blank   but   then   you   get   a   blank   mail
$s_AttachFiles   =   ""                                ;   附件地址   the   file   you   want   to   attach-   leave   blank   if   not   needed
$s_CcAddress   =   ""       ;   address   for   cc   -   leave   blank   if   not   needed
$s_BccAddress   =   ""        ;   address   for   bcc   -   leave   blank   if   not   needed
$s_Username   =   "yidabu"                         ;  用户名   username   for   the   account   used   from   where   the   mail   gets   sent   -   REQUIRED
$s_Password   =   "www.yidabu.com"             ;   密码password   for   the   account   used   from   where   the   mail   gets   sent   -   REQUIRED
$IPPort   =   25                                     ;   发送端口   port   used   for   sending   the   mail
$ssl   =   0                                           ;   安全连接   enables/disables   secure   socket   layer   sending   -   put   to   1   if   using   httpS
;~   $IPPort=465                                      ;   yidabu.com提示:Gmail使用的发送端口  
;~   $ssl=1                                            ;   yidabu.com提示:Gmail要启用安全连接  

;##################################
;   Script
;##################################
Global   $oMyRet[2]
Global   $oMyError   =   ObjEvent("AutoIt.Error",   "MyErrFunc")
;~   $rc   =   _INetSmtpMailCom($s_SmtpServer,   $s_FromName,   $s_FromAddress,   $s_ToAddress,   $s_Subject,   $as_Body,   $s_AttachFiles,   $s_CcAddress,   $s_BccAddress,   $s_Username,   $s_Password,   $IPPort,   $ssl)
;~   If   @error   Then
;~        MsgBox(0,   "Error   sending   message",   "Error   code:"   &   @error   &   " Description:"   &   $rc)
;~   EndIf
;

Func   _INetSmtpMailCom($s_SmtpServer,   $s_FromName,   $s_FromAddress,   $s_ToAddress,   $s_Subject   =   "",   $as_Body   =   "",   $s_AttachFiles   =   "",   $s_CcAddress   =   "",   $s_BccAddress   =   "",   $s_Username   =   "",   $s_Password   =   "",$IPPort=25,   $ssl=0)
   $objEmail   =   ObjCreate("CDO.Message")
   $objEmail.From   =   '"'   &   $s_FromName   &   '"   <'   &   $s_FromAddress   &   '>'
   $objEmail.To   =   $s_ToAddress
   Local   $i_Error   =   0
   Local   $i_Error_desciption   =   ""
   If   $s_CcAddress   <>   ""   Then   $objEmail.Cc   =   $s_CcAddress
   If   $s_BccAddress   <>   ""   Then   $objEmail.Bcc   =   $s_BccAddress
   $objEmail.Subject   =   $s_Subject
   If   StringInStr($as_Body,"<")   and   StringInStr($as_Body,">")   Then
         $objEmail.HTMLBody   =   $as_Body  
   Else
         $objEmail.Textbody   =   $as_Body   &   @CRLF
   EndIf
   If   $s_AttachFiles   <>   ""   Then
         Local   $S_Files2Attach   =   StringSplit($s_AttachFiles,   ";")
         For   $x   =   1   To   $S_Files2Attach[0]
            $S_Files2Attach[$x]   =   _PathFull   ($S_Files2Attach[$x])
            If   FileExists($S_Files2Attach[$x])   Then
                  $objEmail.AddAttachment   ($S_Files2Attach[$x])
            Else
                  $i_Error_desciption   =   $i_Error_desciption   &   @lf   &   'File   not   found   to   attach:   '   &   $S_Files2Attach[$x]
                  SetError(1)
                  return   0
            EndIf
         Next
   EndIf
   $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/sendusing")   =   2
   $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpserver")   =   $s_SmtpServer
   $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")   =   $IPPort
;Authenticated   SMTP
   If   $s_Username   <>   ""   Then
         $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")   =   1
         $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/sendusername")   =   $s_Username
         $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/sendpassword")   =   $s_Password
   EndIf
   If   $Ssl   Then  
         $objEmail.Configuration.Fields.Item   ("http://schemas.microsoft.com/cdo/configuration/smtpusessl")   =   True
   EndIf
;Update   settings
   $objEmail.Configuration.Fields.Update
;   Sent   the   Message
   $objEmail.Send
   if   @error   then  
         SetError(2)
         return   $oMyRet[1]
   EndIf
EndFunc   ;==>_INetSmtpMailCom
;
;
;   Com   Error   Handler
Func   MyErrFunc()
   $HexNumber   =   Hex($oMyError.number,   8)
   $oMyRet[0]   =   $HexNumber
   $oMyRet[1]   =   StringStripWS($oMyError.description,3)
   ConsoleWrite("###   COM   Error   ! Number:   "   &   $HexNumber   &   " ScriptLine:   "   &   $oMyError.scriptline   &   " Description:"   &   $oMyRet[1]   &   @LF)  
   SetError(1);   something   to   check   for   when   this   function   returns
   Return
EndFunc   ;==>MyErrFunc
 楼主| 发表于 2011-9-27 19:30:55 | 显示全部楼层
上述的smtpmailer代码我也找到了,不知道有没有类似于2楼兄弟给出的简单示范或使用说明呢?
 楼主| 发表于 2011-9-30 10:18:55 | 显示全部楼层
代码中有mirosoft网站的Link,请问在计算机无法联网的情况下是否部分功能即使有内部的smtp服务器也无法正常使用呢?
发表于 2011-9-30 19:47:38 | 显示全部楼层
学习一下邮件发送的代码
发表于 2011-10-1 00:12:20 | 显示全部楼层
论坛有SmtpMailer.au3 附件 抄送 暗抄都支持~!~ 个人感觉很不错~提问的时候先搜搜吧~
 楼主| 发表于 2011-10-10 23:35:37 | 显示全部楼层
研究了一下原来smtpmailer.au3是使用cdo.message发送邮件的,也测试成功了。
发表于 2011-12-9 14:29:20 | 显示全部楼层
同求jamail 发送邮件
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-12 17:12 , Processed in 0.087488 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表