Advertisement
flypip

Flend (emetteur de mail)

Oct 22nd, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.03 KB | None | 0 0
  1. #include <ButtonConstants.au3>
  2. #include <EditConstants.au3>
  3. #include <GUIConstantsEx.au3>
  4. #include <WindowsConstants.au3>
  5. $s_SmtpServer="smtp.gmail.com"
  6. $s_FromName="Anonymous"
  7. $s_FromAddress="anonyflend@gmail.com"
  8. $s_ToAddress=""
  9. $s_Subject = ""
  10. $as_Body = ""
  11. $s_AttachFiles = ""
  12. $s_CcAddress = ""
  13. $s_BccAddress = ""
  14. $s_Username = "anonyflend"
  15. $s_Password = "254898334553884"
  16. $IPPort = 465
  17. $ssl = 1
  18. $s_Importance="Normal"
  19. #Region ### START Koda GUI section ### Form=
  20. $Form1 = GUICreate("flend", 224, 196, 192, 124)
  21. $Input1 = GUICtrlCreateInput("", 8, 8, 121, 21)
  22. $Button1 = GUICtrlCreateButton("Flend", 144, 8, 75, 25)
  23. $Input2 = GUICtrlCreateInput("", 8, 40, 209, 21)
  24. $Edit1 = GUICtrlCreateEdit("", 8, 64, 209, 121, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
  25. GUISetState(@SW_SHOW)
  26. #EndRegion ### END Koda GUI section ###
  27.  
  28. While 1
  29.     $nMsg = GUIGetMsg()
  30.     Switch $nMsg
  31.         Case $GUI_EVENT_CLOSE
  32.             Exit
  33.         Case $Button1
  34.             $as_Body = GUICtrlRead($Edit1)
  35.             $s_Subject = GUICtrlRead($Input2)
  36.             $s_ToAddress = GUICtrlRead($Input1)
  37.             _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body , $s_AttachFiles , $s_CcAddress, $s_BccAddress, $s_Importance, $s_Username, $s_Password , $IPPort , $ssl)
  38.             GuiCtrlSetData ($Input2,"")
  39.             GuiCtrlSetData ($Edit1,"")
  40.            
  41.     EndSwitch
  42. WEnd
  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[$x] & @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.  
  76.     ;Authenticated SMTP
  77.     If $s_Username <> "" Then
  78.         $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  79.         $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
  80.         $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
  81.     EndIf
  82.     If $ssl Then
  83.         $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  84.     EndIf
  85.     ;Update settings
  86.     $objEmail.Configuration.Fields.Update
  87.     ; Set Email Importance
  88.     $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High"
  89.     $objEmail.Fields.Update
  90.     ; Sent the Message
  91.     $objEmail.Send
  92.     $objEmail=""
  93. EndFunc   ;==>_INetSmtpMailCom
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement