发送电子邮件至AutoIt

Chr*_*son 10 email autoit

如何用AutoIt发送电子邮件?只需要一个干净的例子和解释,包含:

  • 学科
  • 信息

Cop*_*pas 10

内置代码有两种主要方式,_INetMail()或_INetSmtpMail()

以下是帮助文件中的简单代码示例.如果您对帮助文件未涵盖的工作方式或实施方式有任何具体问题,请发表评论.

在我看来,_INetSmtpMail()路由更合理.下面是一些示例代码.

#include <INet.au3>

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

使用Windows注册的内置邮件客户端的_INetMail()方法.

#include <INet.au3>

$Address = InputBox('Address', 'Enter the E-Mail address to send message to')
$Subject = InputBox('Subject', 'Enter a subject for the E-Mail')
$Body = InputBox('Body', 'Enter the body (message) of the E-Mail')
MsgBox(0,'E-Mail has been opened','The E-Mail has been opened and process identifier for the E-Mail client is ' & _INetMail($address, $subject, $body))
Run Code Online (Sandbox Code Playgroud)