#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_Run_Debug_Mode=Y ;(Y/N) Run Script with console debugging. Default=N #include #include "SmtpMailer.au3" #Region Example Script ;################################## ; Example Script ;################################## _Example() Func _Example() Local $s_SmtpServer = "server" ;ip or servername Local $s_Username = "username" Local $s_Password = "password" Local $s_FromName = "My Name" Local $s_FromAddress = "info@someserver.com" Local $s_ToAddress = "info@someserver.com" Local $s_Subject = "TestMail" Local $b_IsHTMLBody = 2 ;0=Plain text 1=HTML 2=autodetect Local $s_Body = "" ;the message body in plain text or html Local $s_AttachFiles = @ScriptDir & "\picture.jpg" & ";" & @ScriptDir & "\test.txt" ;attch several files, seperated by ; Local $s_CcAddress = "" ;carbon copy to Local $s_BccAddress = "" ;blind carbon copy to Local $s_Importance = "Normal" ; low, normal, high and some other rather exotic values Local $i_IPPort = 25 ;25, 465 or whatever fits your setup Local $b_SSL = True ;use ssl or not Local $s_EMLPath_SaveBefore = "" ;save prepared email to this file Local $s_EMLPath_SaveAfter = "" ;save sent email to this file Local $s_EMLPath_LoadFrom = "" ;load prepared email from this file Local $i_SMTPtimeout = 15 ;15 is recommended, you may need to play with his if you want to send many mails fast without losing some Local $s_ReplyToAdress = "" Local $s_NotificationAdress = "" Local $b_donotsend = False ;for tests or if creating the eml file only Local $i_DSNOptions = $g__cdoDSNDefault ;example1 $s_Body = "Example 1" ;first we create the eml file and save it without sending it $s_EMLPath_SaveBefore = @ScriptDir & "\test1.eml" $b_donotsend = True _SMTP_SendEmail($s_SmtpServer, $s_Username, $s_Password, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Importance, $i_IPPort, $b_SSL, $b_IsHTMLBody, $i_DSNOptions, $s_EMLPath_SaveBefore, $s_EMLPath_SaveAfter, $s_EMLPath_LoadFrom, $i_SMTPtimeout, $s_NotificationAdress, $s_ReplyToAdress, $b_donotsend) ;now we send the prepared eml file $s_EMLPath_SaveAfter = @ScriptDir & "\test2.eml" $s_EMLPath_LoadFrom = @ScriptDir & "\test1.eml" $b_donotsend = False _SMTP_SendEmail($s_SmtpServer, $s_Username, $s_Password, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Importance, $i_IPPort, $b_SSL, $b_IsHTMLBody, $i_DSNOptions, $s_EMLPath_SaveBefore, $s_EMLPath_SaveAfter, $s_EMLPath_LoadFrom, $i_SMTPtimeout, $s_NotificationAdress, $s_ReplyToAdress, $b_donotsend) ;example2 $s_Body = "Example 2" Local $s_ResultDescription = _SMTP_SendEmail($s_SmtpServer, $s_Username, $s_Password, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $s_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Importance, $i_IPPort, $b_SSL, $b_IsHTMLBody, $i_DSNOptions, $s_EMLPath_SaveBefore, $s_EMLPath_SaveAfter, $s_EMLPath_LoadFrom, $i_SMTPtimeout, $s_NotificationAdress, $s_ReplyToAdress, $b_donotsend) If Not @error Then Return SetError(@error, @extended, $s_ResultDescription) ElseIf @error = $SMTP_ERR_SEND Then ConsoleWrite("! Number: " & _SMTP_COMErrorHexNumber() & " UDF Script Line: " & _SMTP_ComErrorScriptLine() & " Description:" & _SMTP_COMErrorDescription() & @LF) MsgBox($MB_ICONERROR, "Error sending email", "_SMTP_SendEmail()" & @CRLF & "Error code: $SMTP_ERR_SEND" & @CRLF & "Description:" & $s_ResultDescription & @CRLF & "COM Error Number: " & _SMTP_COMErrorHexNumber()) Return SetError($SMTP_ERR_SEND, 0, 0) Else ;Return SetError(@error, @extended, 0) EndIf EndFunc ;==>_Example #EndRegion Example Script