Jump to content

SMTP Mailer UDF


mLipok
 Share

Recommended Posts

Hi,

 

i made some additions to the UDF. They may not be perfect, but they seem to work ok for me.

So i decided to upload my version here, just in case someone might need this:

 

Quote

>>>>> 2019/07/05 -> smiley
    - beware: script breaking changes
    - New: Function: _SMTP_LoadMessageFromFile - smiley
    - Added: _SMTP_SendEmail: $s_EMLPath_LoadFrom file with prepared email (overrides many other settings)
    - Added: _SMTP_SendEmail: Missing paramter info in Header for $s_EMLPath_SaveBefore and $s_EMLPath_SaveAfter and also added the _ to be more consistent with varibale names
    - Changed: _SMTP_SendEmail: $b_IsHTMLBody changed to $i_IsHTMLBody to enable HTML Autodected (0=txt, 1=html, anything else AutoDetect)
    - Added _SMTP_SendEmail: $i_SMTP_timeout to set smtp timout (the script loses mails when sending many mails fast. Setting this to 15 fixes this for me)
    - Changed: _SMTP_SendEmail: $s_Importance now in english and german and sets more header values
    - Added: _SMTP_SendEmail: $s_NotificationAdress and only add if adress is given
    - Added: _SMTP_SendEmail: $s_ReplyToAdress parameter
    - Added: _SMTP_SendEmail: $b_donotsend for testrun or to save the eamil to file without sending
    - Added: _SMTP_SendEmail: we set $oEmail.BodyPart.CharSet = "UTF-8" and $oEmail.BodyPart.ContentTransferEncoding = "quoted-printable"
    - Added: _SMTP_SendEmail: all attached files are now set to base64 encoding

SmtpMailerExample.au3 SmtpMailer.au3

Link to comment
Share on other sites

Here are some small changes:

Quote

    >>>>> 2019/07/11 -> smiley
    - Added: _SMTP_SendEmail: example in header was incomplete/incorrect
    - Added: _SMTP_SendEmail: info about returnvalue and added return on success
    - Changed: Split examples in two functions
    - Changed: moved several variables to the udf as global vars so we can load and save configs
    - Added: _SMTP_LoadConfig,_SMTP_SaveConfig
    - Changed: when a notification Adress is given and the DSN options are invalid for notification, we autoset valid dsnoptions

smtpmailer.zip

Link to comment
Share on other sites

  • Developers

@Allow2010,

Don't you think is is somewhat strange to post your own version with changes in somebody's else their thread? 
Either work with the person owning the original script or start your own thread ( to further confuse the hell out of everybody with an third version of my script.   ;) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 7 months later...

Maybe a simple question:

I have to send mail via a mail server and for this server "EHLO" is required.

So this works well:

_INetSmtpMail($INIsmpt, $INIfromname, $INIfromaddress, $INItomail, $INImailsubject, $report, "EHLO " & @ComputerName, "-1")

But I have also to include attachments, and I don't figure out where to PUT the "EHLO" string in this UDF ...

Any ideas ?

 

Edited by t0nZ
Link to comment
Share on other sites

  • Developers
3 minutes ago, t0nZ said:

But I have also to include attachments, and I don't figure out where to PUT the "EHLO" string in this UDF ...

Have you simply tried the script posted here or my version to see whether it works?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I used your script many times when I had to send attachments, normally with Gmail accounts and no problems at all.

But now I have an "open" SMTP company server with no authentication required, no SSL, working only from company LAN but it demands "EHLO" to work.

Tried today also this modified version (searching for maybe a place to insert the "EHLO" parameter) with no success (COM Error !  Number: 80020009   Description:The transport failed to connect to the server)

As stated in my previous post , this ;

Quote

_INetSmtpMail($INIsmpt, $INIfromname, $INIfromaddress, $INItomail, $INImailsubject, $report, "EHLO " & @ComputerName, "-1")

is working, so I guess I have to put somewhere the "EHLO" but dunno where.....

Thanks in advance for your patience...

Edited by t0nZ
Link to comment
Share on other sites

  • Developers

So again, did you try using my script at all for this as that should work too on a straitforward SMTP server as far as I know given you set the parameters correctly.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 1 year later...

Just an example for sending automated reports  by email with data from SQL Server database, with attachment excel file, and send sms if fails.

nothing new, but can help to see the pieces together

#include <File.au3>
#include <Timers.au3>
#include <Excel.au3>
#include <WinAPIFiles.au3>
#include <Misc.au3>
#include "SmtpMailer.au3"

;~ ;for sending SMS
;~ ;Jefrey
;~ ;https://github.com/jesobreira/HTTP.au3
;~ ;https://www.autoitscript.com/forum/topic/187718-http-lib-get-post-and-upload/
;~ #include "HTTP.au3"

;_Singleton("Example", 0)
If _Singleton("Example", 1) = 0 Then
   Msgbox(48,"Warning", "An occurrence of Example is already running", 5)
   Exit
EndIf

AutoItWinSetTitle("Example")

Opt("MustDeclareVars", 1)
Opt("TrayIconDebug", 1)
OnAutoItExitRegister("OnAutoItExit")

;If MsgBox(324, "", "Do you want to proceed?") <> 6 Then Exit

#===== CONFIG =====
Global $sMonth, $sTxt, $sSms
Global $CheckActive = False
Global $bSms = False
Global $CleanLog = True
Global $MesRef = @MON - 1
;Global $nMon = Number($Mon)
Global $aMonths[12] = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]
If $MesRef = 0 Then $MesRef = 12
$sMonth = $aMonths[$MesRef - 1]
Global $sFilePath2 =  @DesktopDir & "\Invoices_" & $sMonth & ".xlsx"
Global $hFile = FileOpen(@DesktopDir & "\Events_Example.log", 2)

If $CheckActive Then
    While 1
        If _Timer_GetIdleTime() > 30000 Then
            ExitLoop
        EndIf
        Sleep(10000)
    WEnd
EndIf

#===== ADODB =====
;Evitar errores en OnAutoItExit
Global $cn, $rst, $sSQL, $SubSQL

;Help: COM Error Handling
;_ErrADODB From spudw2k
;https://www.autoitscript.com/forum/topic/105875-adodb-example/
Global $errADODB = ObjEvent("AutoIt.Error","_ErrADODB")

Global Const $iCursorType = 3 ;0 adOpenForwardOnly, 3 adOpenStatic
Global Const $iLockType = 1 ;1 adLockReadOnly, 3 adLockOptimistic
Global Const $iOptions = 1 ; Options, 1 Evaluates as a textual definition of a command or stored procedure call ; 2 adCmdTable
$cn = ObjCreate("ADODB.Connection") ; Create a connection object
$rst = ObjCreate("ADODB.Recordset") ; Create a recordset object
;~ #==========  MS SQL Server =============
;~ ;https://accessexperts.com/blog/2011/03/24/sql-server-connections-strings-for-microsoft-access/
;~ ;You should bypass the ODBC layer altogether when connecting to SQL Sever by using a connection string similar to this one in your code:
;~ ;stConnect = "Provider=SQLOLEDB;Data Source=...
;~ ;Or if you’re using native client:
;~ ;stConnect = "Provider=SQLNCLI10;Data Source=...
Global $sADOConnectionString = 'Provider=SQLOLEDB;Data Source=XX.X.X.XX;Initial Catalog=MyDataBaseName;User Id=sa;Password=123;'

If $MesRef = 12 Then $sADOConnectionString = StringReplace($sADOConnectionString, "MyDataBase", "MyDataBase" & @YEAR - 1 & "Name")

;https://www.w3schools.com/asp/prop_rs_cursorlocation.asp
;A Recordset object inherits this setting from the associated Connection object.
;This property is read-only on an open Recordset object, and read/write on a Connection object or on a closed Recordset object.
$cn.CursorLocation = 2 ;2 adUseServer, 3 adUseClient
$cn.CommandTimeout = 30

;https://www.w3schools.com/asp/prop_rec_mode.asp
$cn.Mode = 1 ;Read-only

$cn.Open($sADOConnectionString) ; Open the connection
;MsgBox(0,"",$cn.ConnectionString)

$sSQL = "SELECT CAST(INVOICES.CODE AS int) AS CODIGO, Format(INVOICES.DATE, 'dd/MM/yyyy') AS DATE, INVOICES.AMOUNT" _
    & " FROM INVOICES" _
    & " WHERE INVOICES.ID_CLIENT = (SELECT CLIENTS.ID FROM CLIENTS WHERE CLIENTS.CODE = '12345') AND MONTH(INVOICES.DATE) = " & $MesRef _
    & " ORDER BY INVOICES.ID;"
$rst.Open($sSQL, $cn, $iCursorType, $iLockType, $iOptions) ; Issue the SQL query

If Not $rst.EOF = True Then
    Global $rstArray = $rst.GetRows()
    $rst.Close
    Global $RecCount = UBound($rstArray)

    $rst = 0    ;Release the recordset object
    ;$cmd = 0
    $cn.Close ;Close the connection
    $cn = 0 ;Release the connection object

    #===== EXCEL =====
    Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc") ;Install a custom error handler
    Global $iEventError ; to be checked to know if com error occurs. Must be reset after handling.

    Global $oAppl = _Excel_Open(True, False, False, Default, True)

    $oAppl.EnableEvents = False
    $oAppl.DisplayAlerts = False

    ;Create a new workbook with only 1 worksheet
    Global $oWorkbook = _Excel_BookNew($oAppl, 1)

    Sleep(3000)
    $oWorkbook.UpdateLinks = 2 ;xlUpdateLinksNever

    Global $oSheet = $oWorkbook.ActiveSheet

    $oAppl.ActiveWindow.DisplayZeros = False
    $oAppl.ActiveWindow.DisplayGridlines = False

    $oSheet.Columns("A:B").ColumnWidth = 8
    $oSheet.Columns(3).ColumnWidth = 10
    If $iEventError Then
        Consolewrite("+--> Error ColumnWidth" & @CRLF)
        $iEventError = 0 ; Reset after displaying a COM Error occurred
    EndIf

    Global $Rows = $RecCount + 1
    $oSheet.Range("A2:B" & $Rows).HorizontalAlignment = -4108
    $oSheet.Range("B2:B" & $Rows).NumberFormat = "dd/mm;@"
    $oSheet.Range("C2:C" & $Rows).NumberFormat = "#.##0,00"

    Global $aArray1D[3] = ["Fra", "Fecha", "Total"]
    Global $oRange = $oSheet.Range("A1:C1")
    If $iEventError Then
        Consolewrite("+--> Error: $oSheet.Range('A1:C1')" & @CRLF)
        $iEventError = 0 ; Reset after displaying a COM Error occurred
    EndIf
    With $oRange
        .HorizontalAlignment = -4108
        .value = $aArray1D
        ;.Font.Bold = True
        ;.AutoFilter
    EndWith

    _Excel_RangeWrite($oWorkbook, $oSheet, $rstArray, $oSheet.Cells(2, 1))

    ;water, Aug 2016
    ;https://www.autoitscript.com/forum/topic/184041-excel-formatting-cellsborders/?do=findComment&comment=1321855
    ;XlListObjectSourceType Enumeration - https://msdn.microsoft.com/en-us/library/ff820815(v=office.14).aspx
    Global $xlSrcRange = 1
    With $oSheet
        .ListObjects.Add($xlSrcRange, .Range("A1:C" & $Rows), Default, $xlYes).Name = "TB_Datos"
        .ListObjects("TB_Datos").TableStyle = "TableStyleMedium6"
    EndWith

    Global $oPageSetup = $oSheet.PageSetup
    With $oPageSetup
        ;.PrintTitleRows = "$1:$1"
        .PrintTitleColumns = ""
        .PrintArea = ""
        .LeftHeader = "&D"
        .CenterHeader = "Invoices: " & $sMonth
        ;.RightHeader = "&P of &N"
        ;.LeftFooter = "&F {&A}"
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin =  28
        .RightMargin =  28
        .TopMargin =  28
        .BottomMargin =  28
        .HeaderMargin =  15
        .FooterMargin =  15
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = -4142
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = 1
        .Draft = False
        .FirstPageNumber = -4105
        .Order = 1
        .BlackAndWhite = False
        .Zoom = False ;100
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    EndWith

    _Excel_BookSaveAs($oWorkbook, $sFilePath2, $xlOpenXMLWorkbook, True) ;$xlOpenXMLWorkbook  51  ;$xlExcel8  56
    _Excel_BookClose($oWorkbook, False)

    While _WinAPI_FileInUse($sFilePath2)
        Sleep(1000)
    Wend
    Sleep(3000)

    $oAppl.EnableEvents = True
    $oAppl.DisplayAlerts = True

    _Excel_Close($oAppl, False, Default)

    Sleep(5000)

    Global $oStream = ObjCreate("ADODB.Stream")
    $oStream.Type = 2 ; adTypeText
    $oStream.Charset = "utf-8"
    $oStream.LineSeparator = -1 ; adCRLF
    $oStream.Open
    ;https://msdn.microsoft.com/en-us/library/ms678072(v=vs.85).aspx
    ;StreamWriteEnum: 1 adWriteLine
    $oStream.WriteText("<html>", 1)
    $oStream.WriteText("<head>", 1)
    $oStream.WriteText("<style>", 1)
    $oStream.WriteText(".table-PedProd {table-layout: fixed; border-collapse: separate; border-spacing: 1px;}", 1)
    $oStream.WriteText(".table-PedProd th {border: 1px solid #e7e7e7; text-align:center; background-color: #f3f3f3; padding: 0.5rem 0.5rem; word-wrap: break-word;}", 1)
    $oStream.WriteText(".table-PedProd tr:nth-child(even){background-color: #f5f5f0}", 1)
    $oStream.WriteText("</style>", 1)
    $oStream.WriteText("</head>", 1)
    $oStream.WriteText("<body>", 1)

    $oStream.WriteText("<table class='table-PedProd' style='width: 300px;'>", 1)
    $oStream.WriteText("<thead><tr>" _
        & "<th style='width: 30%'>Invoice</th>" _
        & "<th style='width: 30%'>Date</th>" _
        & "<th style='width: 40%'>Amount</th>" _
        & "</tr></thead>", 1)
    $oStream.WriteText("<tbody>", 1)

    For $i = 0 To UBound($rstArray) - 1
        $oStream.WriteText("<tr><td style='text-align:center; word-wrap: break-word;'>" & $rstArray[$i][0] & "</td>", 1)
        $oStream.WriteText("<td style='text-align:center; word-wrap: break-word;'>" & StringLeft($rstArray[$i][1], 5) & "</td>", 1)
        $oStream.WriteText("<td style='text-align:right; word-wrap: break-word; padding-right: 4px;'>" & $rstArray[$i][2] & "</td></tr>", 1)
    Next

    $oStream.WriteText("</tbody>", 1)
    $oStream.WriteText("</table>", 1)

    $oStream.WriteText("</body>", 1)
    $oStream.WriteText("</html>", 1)
    ;Local $sFilePathHTML = @DesktopDir & "\temp.html"
    ;$oStream.SaveToFile($sFilePathHTML, 2) ;adSaveCreateOverWrite
    ;After a call to this method, the current position in the stream is set to the beginning of the stream (Position=0).
    $oStream.Position = 0

    ;Send mail
    Global $sSmtpServer = "mail.somedomain.com"
    Global $sUsername = "mymail@somedomain.com"
    Global $sPassword = "123456"
    Global $sFromName = "My Name"
    Global $sFromAddress = "mymail@somedomain.com"
    Global $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress
    Global $sImportance = "High" ;Send message priority: "High", "Normal", "Low"
    Global $iIPPort = 25
    Global $bSSL = False
    ; 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
    Global $bIsHTMLBody = True
    Global $iDSNOptions = $g__cdoDSNDefault
    Global $sResultDescription

    $sToAddress = "somemail@otherdomain.com"
    $sSubject = "Invoices " & $sMonth
    $sBody = $oStream.ReadText
    $sAttachFiles = $sFilePath2 ;seperated with a ; (Semicolon) - leave blank if not needed
    $sCcAddress = "someccmail@somedomain.com,mymail@somedomain.com"
    $sBccAddress = ""
    $sResultDescription = _SMTP_SendEmail($sSmtpServer, $sUsername, $sPassword, $sFromName, $sFromAddress, $sToAddress, $sSubject, $sBody, $sAttachFiles, $sCcAddress, $sBccAddress, $sImportance, $iIPPort, $bSSL, $bIsHTMLBody, $iDSNOptions)
    If Not @error Then
        MsgBox(262144, "Sent", "Sent", 2)
        SoundPlay(@WindowsDir & "\media\tada.wav", 0) ; Chimes.wav
        $sTxt = "OK"
        Consolewrite($sTxt & @CRLF)
        _FileWriteLog($hFile, $sTxt)
        $sSms = $sTxt
    ElseIf @error = $SMTP_ERR_SEND Then
        ConsoleWrite("! Number: " & _SMTP_COMErrorHexNumber() & "  UDF Script Line: " & _SMTP_ComErrorScriptLine() & "   Description:" & _SMTP_COMErrorDescription() & @LF)
        MsgBox(262144, "Error sending email", "_SMTP_SendEmail()" & @CRLF & "Error code: $SMTP_ERR_SEND" & @CRLF & "Description:" & $sResultDescription & @CRLF & "COM Error Number: "& _SMTP_COMErrorHexNumber())
        $sTxt = "Err email"
        Consolewrite($sTxt & @CRLF)
        _FileWriteLog($hFile, $sTxt)
        $sSms = $sTxt
        $CleanLog = False
    EndIf

    $oStream.Close
    $oStream = 0

    FileRecycle($sFilePath2)
Else
    $rst.Close
    $rst = 0 ; Release the recordset object
    $cn.Close ; Close the connection
    $cn = 0 ; Release the connection object

    $sTxt = "Records Not Found"
    Consolewrite($sTxt & @CRLF)
    _FileWriteLog($hFile, $sTxt)
    $sSms = $sTxt
    $CleanLog = False
    MsgBox(262144, "", $sTxt & @CRLF & "Line script: " & @ScriptLineNumber , 5)
EndIf

Func _ErrADODB()
    $sTxt = "Err ADO: " & $errADODB.description
    Consolewrite($sTxt & @CRLF)
    _FileWriteLog($hFile, $sTxt)
    $sSms = $sTxt
    $CleanLog = False

    Msgbox(0,"ADODB COM Error","We intercepted a COM Error !"      & @CRLF  & @CRLF & _
        "err.description is: "    & @TAB & $errADODB.description    & @CRLF & _
        "err.windescription:"     & @TAB & $errADODB.windescription & @CRLF & _
        "err.number is: "         & @TAB & hex($errADODB.number,8)  & @CRLF & _
        "err.lastdllerror is: "   & @TAB & $errADODB.lastdllerror   & @CRLF & _
        "err.scriptline is: "     & @TAB & $errADODB.scriptline     & @CRLF & _
        "err.source is: "         & @TAB & $errADODB.source         & @CRLF & _
        "err.helpfile is: "       & @TAB & $errADODB.helpfile       & @CRLF & _
        "err.helpcontext is: "    & @TAB & $errADODB.helpcontext, 5)

    Local $err = $errADODB.number
    If $err = 0 Then $err = -1

    ;Devolver datos error
    Local $sFilePath = @DesktopDir &  "\error_Example.txt"
    ;Open the file for write access.
    Local $hFileOpen = FileOpen($sFilePath, 2)
    ;If $hFileOpen = -1 Then
        ;MsgBox(0, "", "An error occurred when reading/writing the file.")
    ;EndIf

    FileWrite($hFileOpen, "ADODB COM Error" & Chr(1) & _
        "err.description is: "    & @TAB & $errADODB.description    & Chr(1) & _
        "err.windescription:"     & @TAB & $errADODB.windescription & Chr(1) & _
        "err.number is: "         & @TAB & hex($errADODB.number,8)  & Chr(1) & _
        "err.lastdllerror is: "   & @TAB & $errADODB.lastdllerror   & Chr(1) & _
        "err.scriptline is: "     & @TAB & $errADODB.scriptline     & Chr(1) & _
        "err.source is: "         & @TAB & $errADODB.source         & Chr(1) & _
        "err.helpfile is: "       & @TAB & $errADODB.helpfile       & Chr(1) & _
        "err.helpcontext is: "    & @TAB & $errADODB.helpcontext _
        )

    ;Close the handle returned by FileOpen.
    FileClose($hFileOpen)

    $rst = 0
    ;$cmd = 0
    $cn.Close
    $cn = 0

    Exit
EndFunc

;This is a custom error handler
Func ErrFunc()
    Local $HexNumber = Hex($oMyError.number, 8)
;~  MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
;~      "Number is: " & $HexNumber & @CRLF & _
;~      "WinDescription is: " & $oMyError.windescription)
    ConsoleWrite("->    We intercepted a COM Error !" & @CRLF & _
        "->    err.number is: " & @TAB & $HexNumber & @CRLF & _
        "->    err.source: " & @TAB & $oMyError.source & @CRLF & _
        "->    err.windescription: " & @TAB & $oMyError.windescription & _
        "->    err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF)

    $iEventError = 1 ; Use to check when a COM Error occurs

    $sTxt = "Err Excel"
    Consolewrite($sTxt & @CRLF)
    _FileWriteLog($hFile, $sTxt)
    $sSms = $sTxt
    $CleanLog = False
EndFunc   ;==>ErrFunc

Func OnAutoItExit()
   FileClose($hFile)
   If $CleanLog Then FileRecycle(@DesktopDir & "\Events_Example.log")

    $rst = 0    ;Release the recordset object
    If IsObj($cn) Then
        If $cn.State > 0 Then $cn.Close ;adStateOpen Close the connection
        $cn = 0 ; Release the connection object
    EndIf

;~  If $bSms = True Then
;~      Global $sResp = _HTTP_Post("http://api.mensatek.com/sms/v5/enviar.php", "Correo=" & URLEncode("mymail@somedomain.com") & "&Passwd=012345&Remitente=MyName&Destinatarios=" & URLEncode("34123456789") & "&Mensaje=" & URLEncode("Example: " & $sSms) & "&Resp=JSON")

;~      ;Open the file for write access.
;~      Global $hFileOpen = FileOpen(@DesktopDir & "\Resp_mensatek_Example.txt", 2)
;~      ;If $hFileOpen = -1 Then
;~      ;MsgBox(0, "", "An error occurred when reading/writing the file.")
;~      ;EndIf
;~      ;Write some data.
;~      FileWrite($hFileOpen, $sResp)
;~      ;Close the handle returned by FileOpen.
;~      FileClose($hFileOpen)
;~  EndIf
EndFunc

 

Link to comment
Share on other sites

  • 4 months later...

@Jos@mLipok

As of May 30, 2022, Google has decided to remove their "Less secure apps sign in" option and Yahoo has done the same. Without this option, _INetSmtpMailCom() no longer works with the same settings it did on May 29, 2022. Does anyone have a work around? Thanks.

Edited by CodeWriter
Link to comment
Share on other sites

9 hours ago, CodeWriter said:

@Jos@mLipok

As of May 30, 2022, Google has decided to remove their "Less secure apps sign in" option and Yahoo has done the same.

Post link to information/documentation.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor 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 APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

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 * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

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) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

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 *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"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: 2023-04-24

Link to comment
Share on other sites

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The AutoHotKey community has been working on this topic ( https://www.autohotkey.com/boards/viewtopic.php?f=76&t=102434) and I have confirmed that their workaround works:

1. Turn on 2-step authentication for Google  (using phone text/call, fob, backup code, etc depending on your preferences) on their Security page

2. Go back to Google Security page and select  the option that now appears: "App Passwords" to generate a "mail" unique Google specific 16-character password

3. Use that generated password in the call to _INetSmtpMailCom() instead of your Gmail account password.

Hope that helps anyone in the same bind.

Link to comment
Share on other sites

  • Developers

I am using the 2factor Authentication with an Set App password for a very long time and that indeed still works fine after this change a Google. :) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 11 months later...

@JosI am using your SMTPMailer UDF (also credit to: @mLipok

The UDF is working like a charm.
However I would like to customize some text in the body of the mail by using bold, colors and/or font size.

Would this be possible using the "standard" mail format or is this only possible if I use HTML ?

Link to comment
Share on other sites

  • 3 months later...

Hello,

May be this question doesnt belong here but i feel this would be a better place to start the question.

While using smtp mail server sent messages arent saved on mailsever in mailbox but are directly sent and hence no record is maintained on server level.(mail server running exim)

While searching on google i found some post where it can be done via imap if m not wrong or through exchange api.

But i feel that will require server modification which here would be out of ambit of autoit forum.

Although i have a very limited exposure and knowledge on the topic.

I request some expert opinion if this can be achieved.]

Thanks in Advance.

Resources that i found of some use:

https://stackoverflow.com/questions/2471218/getting-a-sent-mailmessage-into-the-sent-folder

https://stackoverflow.com/questions/24257524/why-emails-sent-by-smtpclient-does-not-appear-in-sent-items

Link to comment
Share on other sites

  • 8 months later...
  • Developers

That is pretty easy to find when doing a google search on "CDO ReplyTo":  You will see you need to add this CDO field in the script:  

$objEmail.ReplyTo = "WhateverEmail2ReplyTo@mydomain.com"

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

×
×
  • Create New...