Jump to content

Stuck with easendmail com? (without registering dll )


Recommended Posts

Hello,

I'm trying to get easendmail.dll to work without registering the dll it would mean we can email via tls and we don't have to rely on cdo anymore because it has some odd flaws.

I tried to figure it out from this forum post:

 

https://www.emailarchitect.net/easendmail

The code below works with a registered dll but I hoped I would get it to work without I tried to use the manifest file that came with easendmail sample also that didn't work.

Strange is that some bits work .. I can see it authenticates on the mailserver ... but actually sending the body (educated guess) results in a strange exit code of autoit.

On the server side it just disconnects after authenticating.

 

Before send
!>20:54:21 AutoIt3.exe ended.rc:-1073741819
+>20:54:21 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 3.173

 

I hope the code below can be of use for someone .... it does work if easendmail is registered. :)

My end goal would be to convert it to base64 and embed everything in the exe.  (maybe using that MT.exe to embed the manifest?

If anyone has a clue in what direction I have to look I would be very grateful.

 

Local $oMyError = ObjEvent("AutoIt.Error", "ErrFunc")

Global Const $sCLSID_Mail = "{DF8A4FE2-221A-4504-987A-3FD4720DB929}"
$EASendMailObjLib = @ScriptDir & "\EASendMailObj.dll"

Global $hDLL = DllOpen($EASendMailObjLib) ; path to the dll

; Create object
$oSmtp = ObjCreate($sCLSID_Mail, Default, $hDLL)



$oSmtp.LicenseCode = "TryIt"

;~     ' Set your sender email address
$oSmtp.FromAddr = "test@domain.nl"
;~     ' Add recipient email address
$oSmtp.AddRecipient("test","monitor@domain.nl",0)

;~     ' Set email subject
$oSmtp.Subject = "simple email from VB 6.0 project"
;~     ' Set email body
$oSmtp.BodyText = "this is a test email sent from VB 6.0 project, do not reply."

 $oSmtp.BodyFormat = 1


;~     ' Your SMTP server address
$oSmtp.ServerAddr = "mail.domain.nl"

;~     ' User and password for ESMTP authentication, if your server doesn't require
;~     ' User authentication, please remove the following codes.
$oSmtp.UserName = "account@domain.nl"
$oSmtp.Password = "password"

;~     ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically
$oSmtp.ConnectType = 0


;~     ' If your server uses 587 port
$oSmtp.ServerPort = 25
;~     ' If your server uses 25/587/465 port with SSL/TLS
;~     ' oSmtp.ConnectType = ConnectSSLAuto
;~     ' oSmtp.ServerPort = 25 ' 25 or 587 or 465



ConsoleWrite("Before send" & @CRLF)
ConsoleWrite("Test" & $oSmtp.SendMail() & @CRLF)
ConsoleWrite($oSmtp.GetLastError()  & @CRLF)
ConsoleWrite($oSmtp.GetLastErrDescription()  & @CRLF)

Sleep(10000)
DllClose($EASendMailObjLib)

; This is a custom error handler
Func ErrFunc($oError)
    Local $bHexNumber = Hex($oError.number, 8)
    ConsoleWrite(@CRLF & @CRLF & "We intercepted a COM Error ! " & _
            " Number: 0x " & Hex($oError.number, 8) & @CRLF & _
            "Description: " & $oError.windescription & _
            "At line: " & $oError.scriptline & @CRLF & @CRLF & _
            "@AutoItVersion = " & @AutoItVersion & @CRLF & _
            "@AutoItX64 = " & @AutoItX64 & @CRLF & _
            "@Compiled = " & @Compiled & @CRLF & _
            "@OSArch = " & @OSArch & @CRLF & _
            "@OSVersion = " & @OSVersion & @CRLF & _
            "Scriptline = " & $oError.scriptline & @CRLF & _
            "NumberHex = " & $bHexNumber & @CRLF & _
            "Number = " & $oError.number & @CRLF & _
            "WinDescription = " & StringStripWS($oError.WinDescription, 2) & @CRLF & _
            "Description = " & StringStripWS($oError.Description, 2) & @CRLF & _
            "Source = " & $oError.Source & @CRLF & _
            "HelpFile = " & $oError.HelpFile & @CRLF & _
            "HelpContext = " & $oError.HelpContext & @CRLF & _
            "LastDllError = " & $oError.LastDllError & @CRLF)                 
                 
EndFunc   ;==>ErrFunc

 

 

Edited by pdvos
Link to comment
Share on other sites

NOTE:  This assumes that you are using a compiled AutoIt script (.exe), not AutoItX DLL.  I mention this because you posted your topic to AutoItX Help & Support forum not AutoIt General Help & Support.

The most likely reason that an executable is not recognizing external manifest information is because it probably has a manifest embedded in the executable.  Compiled AutoIt executables have an embedded manifest.  If an executable has an embedded manifest, it will not look for a Side-by-Side (SxS)/external manifest.  So you can do one of 2 things, you can add the additional manifest information into the embedded manifest or you can remove the embedded manifest and create an external one. 

A long time ago, I created a script that automatically does this modification of a compiled AutoIt executable.  I created it because I was playing with Chilkat Software's utilities. Chilkat also offers a COM/ActiveX version that can be run registration-free.  My SxS Manifest Tool, as I called it, was created as a console app so that I could run it standalone or by using the #AutoIt3Wrapper_Run_After directive during the compile process of the script that used the COM DLL.  Below is a summary of what it did or what needs to be done to create an external SxS/Registration-Free version of your app:

  1. My tool required 2 parameters as input, the executable's path and the COM's manifest file.
  2. Using that info, it would extract the embedded manifest from the executable file.
  3. I would then read the COM's manifest file and add the COM's manifest information to extracted manifest.
  4. I would then write the new external manifest file -- naming it the exe's file name with ".manifest" appended to it.
  5. Lastly, I would remove the reference to the embedded manifest file from the original executable.

That's it.  For the record, it was all done using pure AutoIt without any need for external utilities like ResourceHacker.  Although, if I were going to do the process manually, I would definitely have used either ResourceHacker or a tool like it.  Once you've create a SxS version of an app a few times, its quite simple and intuitive.

Hopefully that points you in the right direction and gives you enough information for you to work with in order to make your own SxS version of an AutoIt EASendMail app.

Edited by TheXman
Link to comment
Share on other sites

Hi TheXman,

Thank you for the pointers :)

I hope to find out and make a step 6 and replace the embedded manifest just to have it all in a single exe. :)

But small steps .. 💪

Edit: I used resource hacker to replace the manifest worked :)

@TheXman Thank you very much!

 

 

 

I'll report this an hope to get this moved to the Autoit side.. 🙈

Edited by pdvos
update progress
Link to comment
Share on other sites

5 hours ago, pdvos said:

Edit: I used resource hacker to replace the manifest worked :)

@TheXman Thank you very much!

You're welcome!  I'm glad that you were able to get it working.  :thumbsup:

If/when you chose to automate the process like I did, the APIs that you will need are in the WinApiRes.au3 UDF library that is distributed with AutoIt.  Help for those APIs can be found in the Help file under: User-Defined Functions Reference -> WinAPIEx Reference -> Menus & Resource Reference -> Resources Management.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...