corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", _
$s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
Local $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])
; ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;
If FileExists($S_Files2Attach[$x]) Then
ConsoleWrite('File attachment added: ' & $S_Files2Attach[$x] & @LF)
$objEmail.AddAttachment($S_Files2Attach[$x])
Else
ConsoleWrite('File attachment NOT added: ' & $S_Files2Attach[$x] & @LF)
SetError(1)
exitloop
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item ("http:) = 2 ; 2 = cdoSendUsingPort
$objEmail.Configuration.Fields.Item ("http:) = $s_SmtpServer
If Number($IPPort) = 0 then $IPPort = 25
$objEmail.Configuration.Fields.Item ("http:) = $IPPort
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item ("http:) = 1
$objEmail.Configuration.Fields.Item ("http:) = $s_Username
$objEmail.Configuration.Fields.Item ("http:) = $s_Password
EndIf
If $ssl == 1 Then
$objEmail.Configuration.Fields.Item ("http:) = True
EndIf
$objEmail.Configuration.Fields.Update
Switch $s_Importance
Case "Highest"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Highest"
$objEmail.Fields.Item ("urn:schemas:mailheader:Priority") = "Highest"
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Priority") = "1 (Highest)"
Case "High"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
$objEmail.Fields.Item ("urn:schemas:mailheader:Priority") = "High"
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Priority") = "2 (High)"
Case "Normal"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal"
$objEmail.Fields.Item ("urn:schemas:mailheader:Priority") = "Normal"
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Priority") = "3 (Normal)"
Case "Low"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low"
$objEmail.Fields.Item ("urn:schemas:mailheader:Priority") = "Low"
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Priority") = "4 (Low)"
Case "Lowest"
$objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Lowest"
$objEmail.Fields.Item ("urn:schemas:mailheader:Priority") = "Lowest"
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Priority") = "5 (Lowest)"
EndSwitch
$objEmail.Fields.Item ("urn:schemas:mailheader:X-Mailer") = "CorzSpaZio"
$objEmail.Fields.Update
$objEmail.Send
If @error Then
SetError(2)
Return $oMyRet[1]
EndIf
$objEmail=""
ConsoleWrite("Sending Mail..." & @LF & @LF & "From:" & $s_FromName & @LF & "From:" & $s_FromAddress & @LF & "To:" & $s_ToAddress & @LF & "Subject:" & _
$s_Subject & @LF & "Body:" & $as_Body & @LF & "Attached:" & $s_AttachFiles & @LF & "CC:" & $s_CcAddress & @LF & "BCC:" & $s_BccAddress & @LF & _
"Priority:" & $s_Importance & @LF & "SMTP User:" & $s_Username & @LF & "SMTP Pass:" & $s_Password & @LF & "Port:" & $IPPort & @LF & _
"SSL:" & ProcessWriteHumanCheckBoxValue($ssl) & @LF)
EndFunc
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description, 3)
ConsoleWrite(" & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
SetError(1)
Return
EndFunc
;