使用内置代码有两种主要方法:_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
_INetMail() 方法使用在 Windows 中注册的内置邮件客户端。
#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))