AutoIT- Sending a mail using the hMailer COM library

Just a simple example on how to use the hMailServer interface.

; Send a mail using the hMailer COM library
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

dim $oMessage

$oMessage = ObjCreate("hMailServer.Message")
$oMessage.From = "Me"
$oMessage.FromAddress = "myaddress@mydomain.com"
$oMessage.Subject = "Hi"
$oMessage.AddRecipient "My friend", "myfriend@myfriend.com"
$oMessage.Body = "Test - This is the contents of the email."
$oMessage.Save

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
			 "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
			 "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
			 "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
			 "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
			 "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
			 "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
			 "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
			 "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
			)
  SetError(1)
Endfunc

See here for more information.

 

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.