Jump to content

Smtp Mailer That Supports Html And Attachments.


Jos
 Share

Recommended Posts

Hi.

I am not that new to Autoit, but I am new to non-standard (included with the installation) UDFs.

I get how this works...but I am not sure how to use it in one of my programs.

Should I pull out the 2 functions, put them in a separate file, and include them? Or should I just copy and paste the whole thing near the top of my script, and then call the function when I need it?

I will be using a string as a value for the body of the message.

Thanks in advance for any advice.

Link to comment
Share on other sites

  • Moderators

The simplest way is at the top of your script put:

#include <Inet.au3>

( I believe that's the include file the emailer is in )

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

The simplest way is at the top of your script put:

#include <Inet.au3>

( I believe that's the include file the emailer is in )

The standard _INetSmtpMail is in that file, but this is a non-standard one.

I did some testing, and answered my own question, so I'll post for future generations:

I put all of the variables up top, and filled some of them out. You can generate new values during your script as necessary. (body, subject, etc)

I also grabbed the:

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

and put them up by the variables...it worked, so...yeah.

Then the Function itself, I just left near the top of my script, and put #Region/#EndRegion around it, so I could collapse it.

Then, when I wanted to send the email (for me, it is last in my script, once the body variable has a bunch of stuff in it), I just used:

$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)
EndIf

And wham-O! It works!

Link to comment
Share on other sites

  • 1 month later...

Very strange why this hasn't been included in the UDF's already.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Developers

Very strange why this hasn't been included in the UDF's already.

Its just me being lazy in making the documentation. :huh2:

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

Thanks for the script

Im trying to use it to send from a machine that dosent have an account to hotmail whilst i was testing

It returns this error

### COM Error ! Number: 80020009 ScriptLine: 111 Description:The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first

This section

$FromAddress = "127.0.0.1"

I tried my email account but this didnt work

I also tried 127.0.0.1

with these settings

$SmtpServer = "smtp.live.com"                   ; address for the smtp-server to use - REQUIRED 
$FromName = "Jez"                               ; name from who the email was sent 
$FromAddress = "127.0.0.1"                  ; address from where the mail should come 
$ToAddress = "myemail@live.co.uk"       ; destination address of the email - REQUIRED 
$Subject = "Userinfo"                           ; subject from the email - can be anything you want it to be 
$Body = "Test"                                          ; the messagebody from the mail - can be left blank but then you get a blank mail 
$AttachFiles = ""                                     ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed 
$CcAddress = "CCadress1@test.com"                     ; address for cc - leave blank if not needed 
$BccAddress = "BCCadress1@test.com"                   ; address for bcc - leave blank if not needed 
$Importance = "Normal"                                ; Send message priority: "High", "Normal", "Low" 
$Username = "myemail@live.co.uk"             ; username for the account used from where the mail gets sent - REQUIRED 
$Password = "############"                                ; password for the account used from where the mail gets sent - REQUIRED 
$IPPort = 587                                          ; port used for sending the mail 
$ssl = 0                                              ; enables/disables secure socket layer sending - put to 1 if using httpS 
;~ $IPPort=465                                        ; GMAIL port used for sending the mail 
;~ $ssl=1                                             ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

Is it possible to hotmail or should i open a Gmail account?

Chimaera

Edited by Chimaera
Link to comment
Share on other sites

Try this >>

$SmtpServer = "smtp.live.com"                   ; address for the smtp-server to use - REQUIRED 
$FromName = "Jez"                               ; name from who the email was sent 
$FromAddress = "127.0.0.1"                  ; address from where the mail should come 
$ToAddress = "#############@live.co.uk"         ; destination address of the email - REQUIRED 
$Subject = "Userinfo"                           ; subject from the email - can be anything you want it to be 
$Body = "Test"                                          ; the messagebody from the mail - can be left blank but then you get a blank mail 
$AttachFiles = ""                                     ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed 
$CcAddress = "CCadress1@test.com"                     ; address for cc - leave blank if not needed 
$BccAddress = "BCCadress1@test.com"                   ; address for bcc - leave blank if not needed 
$Importance = "Normal"                                ; Send message priority: "High", "Normal", "Low" 
$Username = "same as above@live.co.uk"             ; username for the account used from where the mail gets sent - REQUIRED 
$Password = "############"                                ; password for the account used from where the mail gets sent - REQUIRED 
$IPPort = 25                                         ; port used for sending the mail 
$ssl = 1                                              ; enables/disables secure socket layer sending - put to 1 if using httpS ;~ 
; $IPPort=465                                        ; GMAIL port used for sending the mail ;~ 
; $ssl=1                                             ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

Ref: http://ask-leo.com/what_are_windows_live_hotmails_pop3_and_smtp_settings.html

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Sorry i didnt hit enter at right bits thats how mine is and gives the error

### COM Error ! Number: 80020009 ScriptLine: 111 Description:The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first

Ive corrected my earlier post

eEdit tryed port 25 as well

, sorry spotted the ssl = 1 as well, when i read the instructions 0 seemed to = active

working good now

top piece of script

thx for help

Edited by Chimaera
Link to comment
Share on other sites

  • Developers

eEdit tryed port 25 as well

, sorry spotted the ssl = 1 as well, when i read the instructions 0 seemed to = active

That doesn't sound right to me... 1 means SSL enabled.

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

It was this where i went wrong Jos

$ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS

because it was 0 already and the first part of the detail said

; enables/disables

that led me to the assumption that 0 = enables, even though it contradicts what it would be normally, because you guys know so much more than me its best not to contradict so i went with 0 = active as above.

its working now very nice, thanks again

Chimaera

Link to comment
Share on other sites

  • Developers

Why does Kaspersky internet security 2011 mark this as 'suspicious' whenever i try to run the compiled exe?

Have you read?:

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

  • 2 weeks later...

Thank you for this script I have been trying to convert the VBS version of this to AutoIT and I was having some trouble. Curious if the password can be hidden somehow? I am using this with G-Mail and I would like to protect the account if it can be done. BTW I am new to scripting and I am working on my first script so please use small words and point at pictures alot :)

Link to comment
Share on other sites

  • Developers

I try use the mail.com smtp and get this error...

### COM Error ! Number: 80020009 ScriptLine: 132 Description:Falha na conexão do transporte com o servidor.

How to fix?

With the info specified, all I can say: Just specify the correct parameters and things will work.

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

  • 2 weeks later...
  • 1 month later...

hellow im having a problem with this udf.

email successfully sent on my home computer (xp 32bit)

but email can't be sent using a computer (xp 32bit) on my computer shop..

error func returns

### COM Error !  Number: 800401F3   ScriptLine: 101   Description:
### COM Error !  Number: 000000A9   ScriptLine: 102   Description:
### COM Error !  Number: 000000A9   ScriptLine: 103   Description:
### COM Error !  Number: 000000A9   ScriptLine: 108   Description:
### COM Error !  Number: 000000A9   ScriptLine: 112   Description:
@@ Debug(62) : $S_Files2Attach =
>Error code: 0
### COM Error !  Number: 000000A9   ScriptLine: 120   Description:
### COM Error !  Number: 000000A9   ScriptLine: 128   Description:
### COM Error !  Number: 000000A9   ScriptLine: 129   Description:
### COM Error !  Number: 000000A9   ScriptLine: 131   Description:
### COM Error !  Number: 000000A9   ScriptLine: 133   Description:
### COM Error !  Number: 000000A9   ScriptLine: 134   Description:
### COM Error !  Number: 000000A9   ScriptLine: 135   Description:
### COM Error !  Number: 000000A9   ScriptLine: 138   Description:
### COM Error !  Number: 000000A9   ScriptLine: 140   Description:
### COM Error !  Number: 000000A9   ScriptLine: 143   Description:
### COM Error !  Number: 000000A9   ScriptLine: 149   Description:
### COM Error !  Number: 000000A9   ScriptLine: 150   Description:

ive already tried to regsvr32 cdosys.dll and cdo.dll .. still not working!

Link to comment
Share on other sites

0x800401F3 means "invalid class string".

Can you please post your script because line 101 is a comment line in Jos's script.

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

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...