Darksider3

lol

Jul 31st, 2010
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.99 KB | None | 0 0
  1. ; Script Start - Add your code below here
  2. ;
  3. ;##################################
  4. ; Include
  5. ;##################################
  6. #include<file.au3>
  7. ;##################################
  8. ; Variables
  9. ;##################################
  10. $SmtpServer = "darksider3@live.de" ; address for the smtp-server to use - REQUIRED
  11. $FromName = "Bill" ; name from who the email was sent
  12. $FromAddress = "Bill_GAtes@microsoft.de" ; address from where the mail should come
  13. $ToAddress = "dk2-game@web.de" ; destination address of the email - REQUIRED
  14. $Subject = "RECHNUNG:" ; subject from the email - can be anything you want it to be
  15. $Body = "lol.." ; the messagebody from the mail - can be left blank but then you get a blank mail
  16. $CcAddress = "RECHNUNG" ; address for cc - leave blank if not needed
  17. $BccAddress = "RECHNUNG" ; address for bcc - leave blank if not needed
  18. $Importance = "High" ; Send message priority: "High", "Normal", "Low"
  19. $Username = "darksider3@live.de" ; username for the account used from where the mail gets sent - REQUIRED
  20. $Password = "PW" ; password for the account used from where the mail gets sent - REQUIRED
  21. $IPPort = 25 ; port used for sending the mail
  22. $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
  23. ;~ $IPPort=465                          ; GMAIL port used for sending the mail
  24. ;~ $ssl=1                               ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS
  25.  
  26.  
  27. ;##################################
  28. ; Script
  29. ;##################################
  30. Global $oMyRet[2]
  31. Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
  32.  
  33.  
  34. $rc = _INetSmtpMail($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
  35.  
  36. If @error Then
  37.     MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
  38.     Exit
  39. EndIf
  40.  
  41. ;
  42. ; The UDF
  43. 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)
  44.     Local $objEmail = ObjCreate("CDO.Message")
  45.     $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
  46.     $objEmail.To = $s_ToAddress
  47.     Local $i_Error = 0
  48.     Local $i_Error_desciption = ""
  49.     If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
  50.     If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
  51.     $objEmail.Subject = $s_Subject
  52.     If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
  53.         $objEmail.HTMLBody = $as_Body
  54.     Else
  55.         $objEmail.Textbody = $as_Body & @CRLF
  56.     EndIf
  57.     If $s_AttachFiles <> "" Then
  58.         Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
  59.         For $x = 1 To $S_Files2Attach[0]
  60.             $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
  61.             ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
  62.             If FileExists($S_Files2Attach[$x]) Then
  63.                 $objEmail.AddAttachment($S_Files2Attach[$x])
  64.             Else
  65.                 ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
  66.                 SetError(1)
  67.                 Return 0
  68.             EndIf
  69.         Next
  70.     EndIf
  71.     $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  72.     $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
  73.     If Number($IPPort) = 0 Then $IPPort = 25
  74.     $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
  75.     ;Authenticated SMTP
  76.     If $s_Username <> "" Then
  77.         $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  78.         $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
  79.         $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
  80.     EndIf
  81.     If $ssl Then
  82.         $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  83.     EndIf
  84.     ;Update settings
  85.     $objEmail.Configuration.Fields.Update
  86.     ; Set Email Importance
  87.     Switch $s_Importance
  88.         Case "High"
  89.             $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High"
  90.         Case "Normal"
  91.             $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal"
  92.         Case "Low"
  93.             $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low"
  94.     EndSwitch
  95.     $objEmail.Fields.Update
  96.     ; Sent the Message
  97.     $objEmail.Send
  98.     If @error Then
  99.         SetError(2)
  100.         Return $oMyRet[1]
  101.     EndIf
  102.     $objEmail = ""
  103. EndFunc   ;==>_INetSmtpMailCom
  104. ;
  105. ;
  106. ; Com Error Handler
  107. Func MyErrFunc()
  108.     $HexNumber = Hex($oMyError.number, 8)
  109.     $oMyRet[0] = $HexNumber
  110.     $oMyRet[1] = StringStripWS($oMyError.description, 3)
  111.     ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
  112.     SetError(1); something to check for when this function returns
  113.     Return
  114. EndFunc   ;==>MyErrFunc
Add Comment
Please, Sign In to add comment