Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. ; Includes
  2. #include <GUIConstantsEx.au3>
  3. #include <IE.au3>
  4. #include <WindowsConstants.au3>
  5.  
  6. ; Create GUI Window
  7. $windowMain = GUICreate("Embedded Outlook Client", 1001, 701, 242, 88, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
  8. ; Display GUI
  9. GUISetState(@SW_SHOW)
  10.  
  11. ; Create an outline for the Embedded Browser
  12. $guiEmailGroup = GUICtrlCreateGroup("", 8, 48, 801, 601)
  13. ; Initiate function
  14. Local $oIE = _IECreateEmbedded()
  15. ; Created an embedded browser
  16. $browserObj = GUICtrlCreateObj($oIE, 20, 60, 780, 580)
  17. ; Allow the browser to be resized if the window is maximized.
  18. GUICtrlSetResizing ( $browserObj, $GUI_DOCKAUTO)
  19. ; Navigate to Outlook
  20. _IENavigate($oIE, "https://outlook.office.com/owa/#path=/mail")
  21.  
  22. While 1
  23. $nMsg = GUIGetMsg()
  24. Switch $nMsg
  25. Case $GUI_EVENT_CLOSE
  26. Exit
  27. EndSwitch
  28. WEnd
  29.  
  30. 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)
  31. Local $objEmail = ObjCreate("CDO.Message")
  32. $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
  33. $objEmail.To = $s_ToAddress ; was $objEmail.To
  34. Local $i_Error = 0
  35. Local $i_Error_desciption = ""
  36. If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
  37. If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
  38. $objEmail.Subject = $s_Subject
  39. If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
  40. $objEmail.HTMLBody = $as_Body
  41. Else
  42. $objEmail.Textbody = $as_Body & @CRLF
  43. EndIf
  44. If $s_AttachFiles <> "" Then
  45. Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
  46. For $x = 1 To $S_Files2Attach[0]
  47. $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
  48. ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console
  49. If FileExists($S_Files2Attach[$x]) Then
  50. ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF)
  51. $objEmail.AddAttachment($S_Files2Attach[$x])
  52. Else
  53. ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
  54. SetError(1)
  55. Return 0
  56. EndIf
  57. Next
  58. EndIf
  59. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  60. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
  61. If Number($IPPort) = 0 Then $IPPort = 25
  62. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
  63. ;Authenticated SMTP
  64. If $s_Username <> "" Then
  65. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
  66. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
  67. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
  68. EndIf
  69. If $ssl Then
  70. $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
  71. EndIf
  72. ;Update settings
  73. $objEmail.Configuration.Fields.Update
  74. ; Set Email Importance
  75. Switch $s_Importance
  76. Case "High"
  77. $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High"
  78. Case "Normal"
  79. $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal"
  80. Case "Low"
  81. $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low"
  82. EndSwitch
  83. $objEmail.Fields.Update
  84. ; Sent the Message
  85. $objEmail.Send
  86. If @error Then
  87. SetError(2)
  88. Return $oMyRet[1]
  89. EndIf
  90. $objEmail = ""
  91. EndFunc ;==>_INetSmtpMailCom
  92. ; Com Error Handler
  93. Func MyErrFunc()
  94. $HexNumber = Hex($oMyError.number, 8)
  95. $oMyRet[0] = $HexNumber
  96. $oMyRet[1] = StringStripWS($oMyError.description, 3)
  97. ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description: " & $oMyRet[1] & @LF)
  98. SetError(1); something to check for when this function returns
  99. Return
  100. EndFunc ;==>MyErrFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement