mLipok

Chilkatsoft Component Example

6 posts in this topic

I played around a little with http://www.chilkatsoft.com/ ActiveX components.
Here is an example based on examples from this page.
 
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>


;~ http://www.chilkatsoft.com/downloads_ActiveX.asp
;~ http://www.chilkatsoft.com/support.asp
;~ http://www.chilkatsoft.com/refdoc/activex.asp
;~ http://www.chilkatsoft.com/refdoc/xChilkatCertStoreRef.html
;~ http://www.chilkatsoft.com/refdoc/xChilkatCertChainRef.html

;~ Email ActiveX Reference Documentation
;~ http://www.chilkatsoft.com/refdoc/xChilkatEmailRef.html

;~ http://www.example-code.com/vbscript/emailObj.asp
;~ http://www.example-code.com/vbscript/pop3.asp

Global $_sPOP3_Server = 'xxxxxx'
Global $_sPOP3_UserName = 'xxxxxx'
Global $_sPOP3_Password = 'xxxxxx'

_Example_1_Version()
_Example_2_Get_number_of_mesages()
_Example_3_Retrieve_UIDLs_from_POP3_Server()
_Example_4_Save_Email_Attachments_to_Filesystem()

Func _Example_1_Version()
    Local $oCrypt = ObjCreate("Chilkat_9_5_0.Crypt2")
    MsgBox(0, '', $oCrypt.Version)

EndFunc   ;==>_Example_1_Version

Func _Example_2_Get_number_of_mesages()
    ; http://www.example-code.com/vbscript/pop3_mailboxCount.asp
    ;  The mailman object is used for receiving (POP3)
    ;  and sending (SMTP) email.
    ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0
    Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan")

    ;  Any string argument automatically begins the 30-day trial.
    $success = $oMailman.UnlockComponent("30-day trial")
    If ($success <> 1) Then
        MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText)
        Return
    EndIf

    ;  Set the POP3 server's hostname
    $oMailman.MailHost = $_sPOP3_Server

    ;  Set the POP3 login/password.
    $oMailman.PopUsername = $_sPOP3_UserName
    $oMailman.PopPassword = $_sPOP3_Password

    ;  Get the number of messages in the mailbox.

    Local $iNumMessages = $oMailman.GetMailboxCount()
    MsgBox(0, '', $iNumMessages)

EndFunc   ;==>_Example_2_Get_number_of_mesages

Func _Example_3_Retrieve_UIDLs_from_POP3_Server()
    ; Retrieve UIDL's from POP3 Server
    ; http://www.example-code.com/vbscript/pop3_getUidls.asp

    ;  The mailman object is used for receiving (POP3)
    ;  and sending (SMTP) email.
    ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0
    Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan")

    ;  Any string argument automatically begins the 30-day trial.
    $success = $oMailman.UnlockComponent("30-day trial")
    If ($success <> 1) Then
        MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText)
        Return
    EndIf

    ;  Set the POP3 server's hostname
    $oMailman.MailHost = $_sPOP3_Server

    ;  Set the POP3 login/password.
    $oMailman.PopUsername = $_sPOP3_UserName
    $oMailman.PopPassword = $_sPOP3_Password

    ; sa is a Chilkat_9_5_0.StringArray
    Local $oSA = $oMailman.GetUidls()

    Local $iCount = $oSA.Count

    For $i = 0 To $iCount - 1
        ConsoleWrite($oSA.GetString($i) & @CRLF)
    Next

EndFunc   ;==>_Example_3_Retrieve_UIDLs_from_POP3_Server

Func _Example_4_Save_Email_Attachments_to_Filesystem()
    ; Save Email Attachments to Filesystem
    ; http://www.example-code.com/vbscript/emailObject_saveAttachments.asp
    Local $oEmail = ObjCreate("Chilkat_9_5_0.Email")

    ;  Load an email object containing attachments.
    ;  This .eml can be downloaded from:
    ;  http://www.example-code.com/testData/HtmlEmail.eml

    Local $sEML_FileFullPath = FileOpenDialog('Choose EML File', @ScriptDir, 'EML file (*.eml)', $FD_FILEMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
        Return 0
    EndIf

    Local $iSuccess = $oEmail.LoadEml($sEML_FileFullPath)
    If ($iSuccess <> 1) Then
        ConsoleWrite($oEmail.LastErrorText & @CRLF)
        Return 0
    EndIf

    ;  If OverwriteExisting is turned on, files with the same
    ;  name are overwritten.  If turned off, new/unique filenames
    ;  are automatically generated.  The filenames actually saved
    ;  are accessible via the GetAttachmentFilename method.
    $oEmail.OverwriteExisting = 1

    ;  Save all attachments to the "myAttachments" subdirectory
    ;  found under the calling process;s current working directory.
    ;  This directory is automatically created if it does not already
    ;  exist.
    $iSuccess = $oEmail.SaveAllAttachments("myAttachments")
    If ($iSuccess <> 1) Then
        ConsoleWrite($oEmail.LastErrorText & @CRLF)
        Return 0
    EndIf

    ;  List the attachment filenames:

    For $i = 0 To $oEmail.NumAttachments - 1
        ConsoleWrite($oEmail.GetAttachmentFilename($i) & @CRLF)
    Next

EndFunc   ;==>_Example_4_Save_Email_Attachments_to_Filesystem

Best regards

mLipok

 

3 people like this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites



Loz

Thanks for like.

btw.

I think I made a separate UDF.
But it takes time.

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

New examples and functions:

 

_Example_5_Unpack_HTML_Email_to_Files()

_EMAIL_html_Viewer_Example()
_INI_SETUP()
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

Global $_sPOP3_Server = _INI_SETUP('POP3_Server')
Global $_sPOP3_UserName = _INI_SETUP('POP3_UserName')
Global $_sPOP3_Password = _INI_SETUP('POP3_Password')

_Example_1_Version()
_Example_2_Get_number_of_mesages()
_Example_3_Retrieve_UIDLs_from_POP3_Server()
_Example_4_Save_Email_Attachments_to_Filesystem()
_Example_5_Unpack_HTML_Email_to_Files()
_EMAIL_html_Viewer_Example()

Func _Example_1_Version()
    Local $oCrypt = ObjCreate("Chilkat_9_5_0.Crypt2")
    MsgBox(0, '', $oCrypt.Version)

EndFunc   ;==>_Example_1_Version

Func _Example_2_Get_number_of_mesages()
    ; http://www.example-code.com/vbscript/pop3_mailboxCount.asp
    ;  The mailman object is used for receiving (POP3)
    ;  and sending (SMTP) email.
    ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0
    Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan")

    ;  Any string argument automatically begins the 30-day trial.
    $success = $oMailman.UnlockComponent("30-day trial")
    If ($success <> 1) Then
        MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText)
        Return
    EndIf

    ;  Set the POP3 server's hostname
    $oMailman.MailHost = $_sPOP3_Server

    ;  Set the POP3 login/password.
    $oMailman.PopUsername = $_sPOP3_UserName
    $oMailman.PopPassword = $_sPOP3_Password

    ;  Get the number of messages in the mailbox.

    Local $iNumMessages = $oMailman.GetMailboxCount()
    MsgBox(0, '', $iNumMessages)

EndFunc   ;==>_Example_2_Get_number_of_mesages

Func _Example_3_Retrieve_UIDLs_from_POP3_Server()
    ; Retrieve UIDL's from POP3 Server
    ; http://www.example-code.com/vbscript/pop3_getUidls.asp

    ;  The mailman object is used for receiving (POP3)
    ;  and sending (SMTP) email.
    ; This ObjCreate statement uses the new single-DLL ActiveX for v9.5.0
    Local $oMailman = ObjCreate("Chilkat_9_5_0.MailMan")

    ;  Any string argument automatically begins the 30-day trial.
    $success = $oMailman.UnlockComponent("30-day trial")
    If ($success <> 1) Then
        MsgBox(0, 'UnlockComponent', $oMailman.LastErrorText)
        Return
    EndIf

    ;  Set the POP3 server's hostname
    $oMailman.MailHost = $_sPOP3_Server

    ;  Set the POP3 login/password.
    $oMailman.PopUsername = $_sPOP3_UserName
    $oMailman.PopPassword = $_sPOP3_Password

    ; sa is a Chilkat_9_5_0.StringArray
    Local $oSA = $oMailman.GetUidls()

    Local $iCount = $oSA.Count

    For $i = 0 To $iCount - 1
        ConsoleWrite($oSA.GetString($i) & @CRLF)
    Next

EndFunc   ;==>_Example_3_Retrieve_UIDLs_from_POP3_Server

Func _Example_4_Save_Email_Attachments_to_Filesystem()
    ; Save Email Attachments to Filesystem
    ; http://www.example-code.com/vbscript/emailObject_saveAttachments.asp
    Local $oEmail = ObjCreate("Chilkat_9_5_0.Email")

    ;  Load an email object containing attachments.
    ;  This .eml can be downloaded from:
    ;  http://www.example-code.com/testData/HtmlEmail.eml

    Local $sEML_FileFullPath = FileOpenDialog('Choose EML File', @ScriptDir, 'EML file (*.eml)', $FD_FILEMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
        Return 0
    EndIf

    Local $iSuccess = $oEmail.LoadEml($sEML_FileFullPath)
    If ($iSuccess <> 1) Then
        ConsoleWrite($oEmail.LastErrorText & @CRLF)
        Return 0
    EndIf

    ;  If OverwriteExisting is turned on, files with the same
    ;  name are overwritten.  If turned off, new/unique filenames
    ;  are automatically generated.  The filenames actually saved
    ;  are accessible via the GetAttachmentFilename method.
    $oEmail.OverwriteExisting = 1

    ;  Save all attachments to the "myAttachments" subdirectory
    ;  found under the calling process;s current working directory.
    ;  This directory is automatically created if it does not already
    ;  exist.
    $iSuccess = $oEmail.SaveAllAttachments("myAttachments")
    If ($iSuccess <> 1) Then
        ConsoleWrite($oEmail.LastErrorText & @CRLF)
        Return 0
    EndIf

    ;  List the attachment filenames:

    For $i = 0 To $oEmail.NumAttachments - 1
        ConsoleWrite($oEmail.GetAttachmentFilename($i) & @CRLF)
    Next

EndFunc   ;==>_Example_4_Save_Email_Attachments_to_Filesystem

Func _Example_5_Unpack_HTML_Email_to_Files($sHTMLFilename = "thisEmail.html")
    ; Unpack HTML Email to Files
    ; http://www.example-code.com/vbscript/email_unpackHtml.asp

    ; This CreateObject statement uses the new single-DLL ActiveX for v9.5.0
    Local $oEmail = ObjCreate("Chilkat_9_5_0.Email")

    ;  Select EML File containing HTML content with images.
    Local $sEML_FileFullPath = FileOpenDialog('Choose EML File', @ScriptDir, 'EML file (*.eml)', $FD_FILEMUSTEXIST)
    If @error Then
        ; Display the error message.
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.")
        Return 0
    EndIf

    ;  Load an email object containing HTML content with images.
    Local $iSuccess = $oEmail.LoadEml($sEML_FileFullPath)
    If ($iSuccess <> 1) Then
        ConsoleWrite($oEmail.LastErrorText & @CRLF)
        Return 0
    EndIf

    ;  Is this an HTML email?
    If ($oEmail.HasHtmlBody() = 1) Then

        ;  Unpack the HTML to files.  The image and css URLs
        ;  in the HTML are modified to point to the files extracted to disk.
        Local $sUnpackDir = @ScriptDir & "\ExtractedHTML"
        Local $sHTMLFileFullPath = $sUnpackDir & '\' & $sHTMLFilename
        Local $sPartsSubdir = "images"

        $iSuccess = $oEmail.UnpackHtml($sUnpackDir, $sHTMLFilename, $sPartsSubdir)
        If ($iSuccess <> 1) Then
            ConsoleWrite($oEmail.LastErrorText & @CRLF)
            Return 0
        EndIf

        ;  If the UnpackHtml method was successful, the
        ;  HTML is written to /temp/thisEmail.html and
        ;  the image files are located in  /temp/images

        Return $sHTMLFileFullPath
    EndIf
EndFunc   ;==>_Example_5_Unpack_HTML_Email_to_Files


Func _EMAIL_html_Viewer_Example($sHTMLFileFullPath = @ScriptDir & "\ExtractedHTML\thisEmail.html")

        If Not FileExists($sHTMLFileFullPath ) Then Return SetError(1,0,0)

        Local $oIE = _IECreateEmbedded()
        GUICreate("Embedded Web control Test", 640, 580, _
                (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
                $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
        GUICtrlCreateObj($oIE, 10, 40, 600, 360)
        GUISetState(@SW_SHOW) ;Show GUI

        Local $sUnpackDir = StringRegExp($sHTMLFileFullPath,'(?i)(.+)\\.+?',3)[0]

        Local $hFileOpen = FileOpen($sHTMLFileFullPath, $FO_READ)
        Local $sHTML = FileRead($hFileOpen)
        FileClose($hFileOpen)

        _html_imgSrcToLocalPath($sHTML,$sUnpackDir)

        _IENavigate($oIE, "about:blank")
        _IEDocWriteHTML($oIE, $sHTML)
;~      _IEAction($oIE, "refresh")

        ; Waiting for user to close the window
        While 1
            Local $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop
            EndSelect
        WEnd

        GUIDelete()


EndFunc


; #FUNCTION# ====================================================================================================================
; Name ..........: _html_imgSrcToLocalPath
; Description ...: Change relative Path to direct local path in HTML source
; Syntax ........: _html_imgSrcToLocalPath(Byref $sHTML[, $sPath = @ScriptDir])
; Parameters ....: $sHTML               - [in/out] a string value.
;                  $sPath               - [optional] a string value. Default is @ScriptDir.
; Return values .: None
; Author ........: SmOke_N
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/167535-iedocwritehtml-extractedhtml/#entry1225920
; Example .......: No
; ===============================================================================================================================
Func _html_imgSrcToLocalPath(ByRef $sHTML, $sPath = @ScriptDir)

    Local $aImgFiles = StringRegExp($sHTML, "(?is)(<\s*img\s+src=[""'](.+?)[""'])", 3)
    If @error Then ; no img files
        Return SetError(1, 0, 0)
    EndIf

    $sPath = StringReplace(StringRegExpReplace($sPath, "[\\/]+$", ""), "\", "/", 0, 1)
    Local $sRepl
    For $i = 0 To UBound($aImgFiles) -1 Step 2
        If StringRegExp($aImgFiles[$i + 1], "^(?i)\s*(http|s?ftp|file:///)") Then ContinueLoop
        $sRepl = StringReplace($aImgFiles[$i], $aImgFiles[$i + 1], _
            "file:///" & $sPath & "/" & $aImgFiles[$i + 1])
        $sHTML = StringReplace($sHTML, $aImgFiles[$i], $sRepl, 1, 0)
    Next

    Return 1
EndFunc


Func _INI_SETUP($sKey)
    Local $sINIFileFullPath = @ScriptFullPath & '.INI'
    Local $sINI_Value = IniRead( $sINIFileFullPath, "POP3", $sKey, 'Default' )
    If $sINI_Value = 'Default' Or $sINI_Value = '' Then
        $sINI_Value = InputBox('INI Setup for Key: ' & $sKey, 'Enter value for ini Key: ' & $sKey &'=','')
        IniWrite( $sINIFileFullPath, "POP3", $sKey, IniRead( $sINIFileFullPath, "POP3", $sKey, Default ) )
        Return $sINI_Value
    Else
        Return $sINI_Value
    EndIf

EndFunc

Thanks to @SmOke_N for:

; #FUNCTION# ====================================================================================================================
; Name ..........: _html_imgSrcToLocalPath
; Description ...: Change relative Path to direct local path in HTML source
; Syntax ........: _html_imgSrcToLocalPath(Byref $sHTML[, $sPath = @ScriptDir])
; Parameters ....: $sHTML               - [in/out] a string value.
;                  $sPath               - [optional] a string value. Default is @ScriptDir.
; Return values .: None
; Author ........: SmOke_N
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/167535-iedocwritehtml-extractedhtml/#entry1225920
; Example .......: No
; ===============================================================================================================================
Func _html_imgSrcToLocalPath(ByRef $sHTML, $sPath = @ScriptDir)

    Local $aImgFiles = StringRegExp($sHTML, "(?is)(<\s*img\s+src=[""'](.+?)[""'])", 3)
    If @error Then ; no img files
        Return SetError(1, 0, 0)
    EndIf

    $sPath = StringReplace(StringRegExpReplace($sPath, "[\\/]+$", ""), "\", "/", 0, 1)
    Local $sRepl
    For $i = 0 To UBound($aImgFiles) -1 Step 2
        If StringRegExp($aImgFiles[$i + 1], "^(?i)\s*(http|s?ftp|file:///)") Then ContinueLoop
        $sRepl = StringReplace($aImgFiles[$i], $aImgFiles[$i + 1], _
            "file:///" & $sPath & "/" & $aImgFiles[$i + 1])
        $sHTML = StringReplace($sHTML, $aImgFiles[$i], $sRepl, 1, 0)
    Next

    Return 1
EndFunc

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Few new examples:
 

Func _Example_12_JsonObject_PrettyPrint()
    _Log_Chilkat('_Example_12_JsonObject_PrettyPrint')
    ; https://www.example-code.com/vbscript/json_pretty_print.asp
    Local $oJSON = ObjCreate("Chilkat_9_5_0.JsonObject")

    $sJSON_String = "{""name"": ""donut"",""image"":{""fname"": ""donut.jpg"",""w"": 200,""h"": 200},""thumbnail"":{""fname"": ""donutThumb.jpg"",""w"": 32,""h"": 32}}"

    $iSuccess = $oJSON.Load($sJSON_String)
    If ($iSuccess <> 1) Then
        ConsoleWrite($oJSON.LastErrorText & @CRLF)
        Return
    EndIf

    ;  To pretty-print, set the EmitCompact property equal to 0
    $oJSON.EmitCompact = 0

    ;  If bare-LF line endings are desired, turn off EmitCrLf
    ;  Otherwise CRLF line endings are emitted.
    $oJSON.EmitCrLf = 0

    ;  Emit the formatted JSON:
    ConsoleWrite($oJSON.Emit() & @CRLF)
EndFunc   ;==>_Example_12_JsonObject_PrettyPrint

Func _Example_13_JsonObject_IterateMembers()
    _Log_Chilkat('_Example_13_JsonObject_IterateMembers')
    ; https://www.example-code.com/vbscript/json_iterate_members.asp
    Local $oJSON = ObjCreate("Chilkat_9_5_0.JsonObject")

    $sJSON_String = "{ ""id"": 1, ""name"": ""A green door"", ""tags"": [""home"", ""green""], ""price"": 125 }"

    $iSuccess = $oJSON.Load($sJSON_String)
    If ($iSuccess <> 1) Then
        ConsoleWrite($oJSON.LastErrorText & @CRLF)
        Return
    EndIf

    $iNumMembers = $oJSON.Size

    For $iMember_idx = 0 To $iNumMembers - 1

        $sName = $oJSON.NameAt($iMember_idx)
        $sValue = $oJSON.StringAt($iMember_idx)

        ConsoleWrite($sName & ": " & $sValue & @CRLF)

        $iValue = $oJSON.IntAt($iMember_idx)
        ConsoleWrite($sName & " as integer: " & $iValue & @CRLF)
    Next
EndFunc   ;==>_Example_13_JsonObject_IterateMembers

Func _Example_14_JsonObject_CreateDocument()
    _Log_Chilkat('_Example_14_JsonObject_CreateDocument')
    ; https://www.example-code.com/vbscript/create_json.asp
    Local $oJSON = ObjCreate("Chilkat_9_5_0.JsonObject")
    Local $iSuccess
    $iSuccess = $oJSON.AddStringAt(-1,"Title","Pan's Labyrinth")
    $iSuccess = $oJSON.AddStringAt(-1,"Director","Guillermo del Toro")
    $iSuccess = $oJSON.AddStringAt(-1,"Original_Title","El laberinto del fauno")
    $iSuccess = $oJSON.AddIntAt(-1,"Year_Released",2006)
    $oJSON.EmitCompact = 0
    ConsoleWrite($oJSON.Emit() & @CRLF)
EndFunc   ;==>_Example_13_JsonObject_IterateMembers

 

test_CHillkat.au3


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Here is an Chilkat.au3 UDF - modest begining.
I will soon post an update as separate thread.

 

Chilkat_example.au3

Chilkat.au3

1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Finally Chillkat.au3 UDF is released:

 

1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Ubermensch
      By Ubermensch
      Hello,
      I am currently trying to automatically click the "Yes" button in the ActiveX prompt/popup message after opening the IE (html).
      At 1st, I encounter the "Allow Blocked Content". I already resolve it just by changing settings in the IE Options. But after resolving the "Allow Blocked Content", there's a popup message appear.
      I have attached the ActiveX Prompt.
      Here is the 1st code that I try to use.
      #include <IE.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> _IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0) Local $oIE = _IEAttach("", "instance", 1) _IELoadWait($oIE) AdlibRegister("_ActiveXRun",250) Local $oLastName = _IEGetObjByName($oIE, "Text4") Local $oGetItem = _IEGetObjByName($oIE, "getitem") _IEAction($oGetItem, "click") MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem)) Func _ActiveXRun() $retWin = WinGetHandle("[Class:Button]","") $winTitle = "[HANDLE:" & $retWin &"]" $ctrlHandle = ControlGetHandle($winTitle,"", "[CLASS:Button; INSTANCE:2]") $ctrlTitle = "HANDLE:" & $ctrlHandle &"]" WinWaitActive($ctrlTitle,"[CLASS:Button; INSTANCE:2]",10) $k = ControlGetPos($winTitle, "","[CLASS:Button; INSTANCE:2]") $x = $k[0] $y = $k[1] WinActivate ($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?") ControlFocus($winTitle,"An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?","[CLASS:Button; INSTANCE:2]") ControlClick($winTitle, "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y) ControlSend($winTitle, "", "[CLASS:Button; INSTANCE:2]", "{ENTER}", 0) EndFunc Here is the console output.
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" /UserParams +>12:44:11 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0 Keyboard:00000409 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\april\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\april\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.2) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3 +>12:44:11 AU3Check ended.rc:0 >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop "C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\AWD10.1.au3" (31) : ==> Subscript used on non-accessible variable.: $x = $k[0] $x = $k^ ERROR ->12:44:24 AutoIt3.exe ended.rc:1 +>12:44:24 AutoIt3Wrapper Finished. >Exit code: 1 Time: 13.76 I also tried a simpler code.
      include <IE.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> _IECreate("C:\Users\april\Documents\Logo\JRB\AutoIt\AutoBOT\AWD10\sampleAWD10.html",0,1,0) Local $oIE = _IEAttach("", "instance", 1) _IELoadWait($oIE) $k = ControlGetPos("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]") $x = $k[0] $y = $k[1] ControlClick("[CLASS:#32770]", "","[CLASS:Button; INSTANCE:2]","primary",1,$x,$y) Local $oLastName = _IEGetObjByName($oIE, "Text4") Local $oGetItem = _IEGetObjByName($oIE, "getitem") _IEAction($oGetItem, "click") MsgBox($MB_SYSTEMMODAL, "Form Element Value", _IEFormElementGetValue($oGetItem)) There's no error in the console output for the 2nd code I have tried.
      And here is the Window Info for the ActiveX prompt.
      >>>> Window <<<< Title: Internet Explorer Class: #32770 Position: 580, 338 Size: 376, 146 Style: 0x94C808C4 ExStyle: 0x00010101 Handle: 0x00000000001516FA >>>> Control <<<< Class: Button Instance: 2 ClassnameNN: Button2 Name: Advanced (Class): [CLASS:Button; INSTANCE:2] ID: 1 Text: &Yes Position: 184, 77 Size: 80, 22 ControlClick Coords: 37, 12 Style: 0x50010000 ExStyle: 0x00000004 Handle: 0x00000000001215DE >>>> Mouse <<<< Position: 228, 120 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< &No An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction? &Yes >>>> Hidden Text <<<<  

    • legend
      By legend
      Hello
      I'm using the code below to send mails using our internal relay server. 
      We got a Helpdesk system named Remedy. Our users can send us a mails using outlook 2010, and we'll get a ticket.
      The problem is if I send a mail using the above script our ticket system can't display unicode characters, like ex: Æ Ø Å. It will display them as: questionmarks: "? ? ?" inside our ticket system. In the outlook inbox it looks fine showing unicode symbols, but in our ticket system the unicode characters will be replaced by questionmarks.
      The thing is, if they send a mail using outlook, it works fine, but using the script above it doesen't.
      I tried to save my script with encoding: UTF-8 with BOM, but it didn't fix it.
       
      All suggestions are very welcome
       
       
       
       
    • mLipok
      By mLipok
      Here I found a usefull UDF for POP3.
      I modified this UDF.
      You can download it from download section.


      Below you see old description:
       
    • mLipok
      By mLipok
      I want to present POP3.au3 UDF.
      Support topic is here: POP3.au3 UDF
       
      REMARK:
      Quoted-printable.au3 author @ProgAndy
      https://autoit.de/index.php/Thread/11350-UTF8-Sting-Convertieren/?postID=87721#post87721
       
    • mLipok
      By mLipok
      I very long time was using
       

       
       
      In the end, I found that at present my needs I need to modify it. And here it is:
      #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 #Region INCLUDE ;################################## ; Include ;################################## #include <file.au3> #EndRegion INCLUDE #Region Variables ;################################## ; Variables ;################################## Global Enum _ $g__INetSmtpMailCom_ERROR_FileNotFound = 1, _ $g__INetSmtpMailCom_ERROR_Send, _ $g__INetSmtpMailCom_ERROR_ObjectCreation, _ $g__INetSmtpMailCom_ERROR_COUNTER Global Const $g__cdoSendUsingPickup = 1 ; Send message using the local SMTP service pickup directory. Global Const $g__cdoSendUsingPort = 2 ; Send the message using the network (SMTP over the network). Must use this to use Delivery Notification Global Const $g__cdoAnonymous = 0 ; Do not authenticate Global Const $g__cdoBasic = 1 ; basic (clear-text) authentication Global Const $g__cdoNTLM = 2 ; NTLM ; Delivery Status Notifications Global Const $g__cdoDSNDefault = 0 ; None Global Const $g__cdoDSNNever = 1 ; None Global Const $g__cdoDSNFailure = 2 ; Failure Global Const $g__cdoDSNSuccess = 4 ; Success Global Const $g__cdoDSNDelay = 8 ; Delay Global Const $g__cdoDSNSuccessFailOrDelay = 14 ; Success, failure or delay #EndRegion Variables #Region Example Script ;################################## ; Example Script ;################################## ;~ _Example() Func _Example() Local $sSmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED Local $sFromName = "Name" ; name from who the email was sent Local $sFromAddress = "your@Email.Address.com" ; address from where the mail should come Local $sToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED Local $sSubject = "Userinfo" ; subject from the email - can be anything you want it to be Local $sBody = "" ; the messagebody from the mail - can be left blank but then you get a blank mail Local $sAttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed Local $sCcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed Local $sBccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed Local $sImportance = "Normal" ; Send message priority: "High", "Normal", "Low" Local $sUsername = "******" ; username for the account used from where the mail gets sent - REQUIRED Local $sPassword = "********" ; password for the account used from where the mail gets sent - REQUIRED Local $iIPPort = 25 ; port used for sending the mail Local $bSSL = False ; enables/disables secure socket layer sending - set to True if using httpS ; Local $iIPPort = 465 ; GMAIL port used for sending the mail ; Local $bSSL = True ; GMAIL enables/disables secure socket layer sending - set to True if using httpS Local $bIsHTMLBody = False Local $iDSNOptions = $g__cdoDSNDefault Local $rc = _INetSmtpMailCom($sSmtpServer, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress, $sImportance, $sUsername, $sPassword, $iIPPort, $bSSL, $bIsHTMLBody, $iDSNOptions) If @error Then MsgBox(0, "_INetSmtpMailCom(): Error sending message", _ "Error code: " & @error & @CRLF & @CRLF & _ "Error Hex Number: " & _INetSmtpMailCom_ErrHexNumber() & @CRLF & @CRLF & _ "Description: " & _INetSmtpMailCom_ErrDescription() & @CRLF & @CRLF & _ "Description (rc): " & $rc & @CRLF & @CRLF & _ "ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() _ ) ConsoleWrite("### COM Error ! Number: " & _INetSmtpMailCom_ErrHexNumber() & " ScriptLine: " & _INetSmtpMailCom_ErrScriptLine() & " Description:" & _INetSmtpMailCom_ErrDescription() & @LF) EndIf EndFunc ;==>_Example #EndRegion Example Script #Region UDF Functions ; The UDF ; #FUNCTION# ==================================================================================================================== ; Name ..........: _INetSmtpMailCom ; Description ...: ; Syntax ........: _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[, $bSSL = False[, $bIsHTMLBody = False[, $iDSNOptions = $g__cdoDSNDefault]]]]]]]]]]]]) ; Parameters ....: $s_SmtpServer - A string value. ; $s_FromName - A string value. ; $s_FromAddress - A string value. ; $s_ToAddress - A string value. ; $s_Subject - [optional] A string value. Default is "". ; $s_Body - [optional] A string value. Default is "". ; $s_AttachFiles - [optional] A string value. Default is "". ; $s_CcAddress - [optional] A string value. Default is "". ; $s_BccAddress - [optional] A string value. Default is "". ; $s_Importance - [optional] A string value. Default is "Normal". ; $s_Username - [optional] A string value. Default is "". ; $s_Password - [optional] A string value. Default is "". ; $IPPort - [optional] An integer value. Default is 25. ; $bSSL - [optional] A binary value. Default is False. ; $bIsHTMLBody - [optional] A binary value. Default is False. ; $iDSNOptions - [optional] An integer value. Default is $g__cdoDSNDefault. ; Return values .: None ; Author ........: Jos ; Modified ......: mLipok ; Remarks .......: ; Related .......: http://www.autoitscript.com/forum/topic/23860-smtp-mailer-that-supports-html-and-attachments/ ; Link ..........: http://www.autoitscript.com/forum/topic/167292-smtp-mailer-udf/ ; Example .......: Yes ; =============================================================================================================================== Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $s_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $bSSL = False, $bIsHTMLBody = False, $iDSNOptions = $g__cdoDSNDefault) ; init Error Handler _INetSmtpMailCom_ErrObjInit() Local $objEmail = ObjCreate("CDO.Message") If Not IsObj($objEmail) Then Return SetError($g__INetSmtpMailCom_ERROR_ObjectCreation, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) ; Clear previous Err information _INetSmtpMailCom_ErrHexNumber(0) _INetSmtpMailCom_ErrDescription('') _INetSmtpMailCom_ErrScriptLine('') $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject ; Select whether or not the content is sent as plain text or HTM If $bIsHTMLBody Then $objEmail.Textbody = $s_Body & @CRLF Else $objEmail.HTMLBody = $s_Body EndIf ; Add Attachments If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) Return SetError($g__INetSmtpMailCom_ERROR_FileNotFound, 0, 0) EndIf Next EndIf ; Set Email Configuration $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = $g__cdoSendUsingPort $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = $g__cdoBasic $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = $bSSL ;Update Configuration Settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low" EndSwitch ; Set DSN options If $iDSNOptions <> $g__cdoDSNDefault And $iDSNOptions <> $g__cdoDSNNever Then $objEmail.DSNOptions = $iDSNOptions $objEmail.Fields.Item("urn:schemas:mailheader:disposition-notification-to") = $s_FromAddress ;~ $objEmail.Fields.Item("urn:schemas:mailheader:return-receipt-to") = $s_FromAddress EndIf ; Update Importance and Options fields $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then _INetSmtpMailCom_ErrObjCleanUp() Return SetError($g__INetSmtpMailCom_ERROR_Send, Dec(_INetSmtpMailCom_ErrHexNumber()), _INetSmtpMailCom_ErrDescription()) EndIf ; CleanUp $objEmail = "" _INetSmtpMailCom_ErrObjCleanUp() EndFunc ;==>_INetSmtpMailCom ; ; Com Error Handler Func _INetSmtpMailCom_ErrObjInit($bParam = Default) Local Static $oINetSmtpMailCom_Error = Default If $bParam == 'CleanUp' And $oINetSmtpMailCom_Error <> Default Then $oINetSmtpMailCom_Error = '' Return $oINetSmtpMailCom_Error EndIf If $oINetSmtpMailCom_Error = Default Then $oINetSmtpMailCom_Error = ObjEvent("AutoIt.Error", "_INetSmtpMailCom_ErrFunc") EndIf Return $oINetSmtpMailCom_Error EndFunc ;==>_INetSmtpMailCom_ErrObjInit Func _INetSmtpMailCom_ErrObjCleanUp() _INetSmtpMailCom_ErrObjInit('CleanUp') EndFunc ;==>_INetSmtpMailCom_ErrObjCleanUp Func _INetSmtpMailCom_ErrHexNumber($vData = Default) Local Static $vReturn = 0 If $vData <> Default Then $vReturn = $vData Return $vReturn EndFunc ;==>_INetSmtpMailCom_ErrHexNumber Func _INetSmtpMailCom_ErrDescription($sData = Default) Local Static $sReturn = '' If $sData <> Default Then $sReturn = $sData Return $sReturn EndFunc ;==>_INetSmtpMailCom_ErrDescription Func _INetSmtpMailCom_ErrScriptLine($iData = Default) Local Static $iReturn = '' If $iData <> Default Then $iReturn = $iData Return $iReturn EndFunc ;==>_INetSmtpMailCom_ErrScriptLine Func _INetSmtpMailCom_ErrFunc() _INetSmtpMailCom_ErrObjInit() _INetSmtpMailCom_ErrHexNumber(Hex(_INetSmtpMailCom_ErrObjInit().number, 8)) _INetSmtpMailCom_ErrDescription(StringStripWS(_INetSmtpMailCom_ErrObjInit().description, 3)) _INetSmtpMailCom_ErrScriptLine(_INetSmtpMailCom_ErrObjInit().ScriptLine) SetError(1); something to check for when this function returns Return EndFunc ;==>_INetSmtpMailCom_ErrFunc #EndRegion UDF Functions Creating this modification, I had to:
      1. Object Error Handler used only for the duration of the function of Use,
      2. Automatic ErrorHandler CleanUp so that previous ErrorHandler took the job.
      3. Ability to get ErrorNumber and ErrorDescription ErrorScriptLine information even after the end of the function
      4. Elimination of most global variables
       
      mLipok
       
      EDIT: attached SmtpMailer_UDF.au3 file
      EDIT 2: Any comments are welcome.
      EDIT 3: Script CleanUp
      EDIT 4: Download moved to "Download Section" (previously downloaded 379 times)

      EDIT 5: at 2016/01/31 there was many script breaking changes