函数参考


_INetSmtpMail

发送一封电子邮件,不使用外部电子邮件程序.

#include <Inet.au3>
_INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress [,$s_Subject [,$as_Body [,$s_helo [,$s_first [,$b_trace]]]]])

参数

$s_SmtpServer 发送邮件的 SMTP 服务器地址. 可以是字母或数字 IP 地址. 为了打击垃圾邮件, 许多互联网服务供应商要求使用他们的服务器.
例如: "smtp.ispdomain.com", "mail.ispdomain.com" 或 "192.168.1.1"
$s_FromName 消息发送人的名称.
例如: "鲍勃史密斯"
$s_FromAddress 发送邮件的地址.
例如: "bob.smith@mydomain.com".
$s_ToAddress 电子邮件接收地址.
例如: "jane.brown@yourdomain.com"
$s_Subject [可选参数] 电子邮件主题.
$as_Body [可选参数] 电子邮件正文.为一个单一字符串的二维数组.数组中每个值在电子邮件中以 @CRLF 终止.
$s_helo [可选参数] SMTP 服务器连接标识. 默认为 @ComputerName(@计算机名). 如果 SMTP 服务器需要一个“EHLO” 字符串, 则设置字符串为 "EHLO " & @ComputerName.
$s_first [可选参数] 字符串发送之前 SMTP 服务器连接的 helo (默认为 {SPACE}).
$b_trace [可选参数] 跟踪初始窗口的对话框

返回值

成功: 返回 1
失败: 返回 0 并设置 @error
@error: 1 - 参数无效
2 - TCP 无法启动
3 - 无法解析 IP
4 - 无法创建套接字
5x - 无法打开 SMTP 会话. x 代表 SMTP 服务器发出的最后命令索引号.
50x - 无法发送正文. x 代表 $as_Body 正文的行号 (第一行为 0).
5000 - 不能关闭 SMTP 会话

注意/说明

此函数通过 SMTP 服务器直接发送电子邮件,不需使用第三方电子邮件客户端. 要求 AutoIt3 v 3.1.1.97 或更高版本.

相关

_INetMail

示例/演示


#include <Inet.au3>

Local $s_SmtpServer = "mysmtpserver.com.au"
Local $s_FromName = "My Name"
Local $s_FromAddress = "From eMail Address"
Local $s_ToAddress = "To eMail Address"
Local $s_Subject = "My Test UDF"
Local $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
Local $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
Local $err = @error
If $Response = 1 Then
    MsgBox(4096, "Success!", "Mail sent")
Else
    MsgBox(4096, "Error!", "Mail failed with error code " & $err)
EndIf