Jump to content

Smtp Mailer That Supports Html And Attachments.


Recommended Posts

  • Replies 758
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;#

Agree, but first needs to be properly tested to see if everything keeps working and I haven't done that yet.  So ...  input/feedback is welcome before doing so!   My preference is to do this wi

$Body = "one" & @CRLF & "two" & @CRLF & "three" ..... ..... $Body = StringReplace($Body,@CRLF,'<br>') ;~ And now you can send your body message....  

Posted Images

That's why additional error information provided by a COM error handler and more detailed information about the OS your friends use is needed.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

That's why additional error information provided by a COM error handler and more detailed information about the OS your friends use is needed.

 

Yes, I just am not sure how to do that. I tried by adding the following line of code into my function, right by the other error IF statement that calls the error function.

If @error Then MsgBox(48 + 262144, "COM Error", "@error is set to COM error number." & @CRLF & "@error = " & @error)

Will that suffice?

Link to post
Share on other sites

Use this as COM error handler (taken from he example in objEvent from the help file):

Func MyErrFunc($oError)
    MsgBox(0, "COM error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

 

Use this as COM error handler (taken from he example in objEvent from the help file):

Func MyErrFunc($oError)
    MsgBox(0, "COM error", "err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode)
EndFunc

OK, added that function, but exactlyt how do I call it, as it has the oError datatype thingy.

My basic email function is below:

Func mEmailer($e_Sender, $e_Recipient, $e_CcAddress, $e_Subject, $e_Text)
    ; Info for this function by JdeB = http://www.autoitscript.com/forum/index.php?s=&showtopic=23860&view=findpost&p=166575
    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    $objMessage = ObjCreate("CDO.Message")
    With $objMessage
        .Subject = $e_Subject
        .Sender = $e_Sender
        .From = $e_Sender
        .To = $e_Recipient
        .Cc = $e_CcAddress
        .TextBody = $e_Text
    EndWith
    With $objMessage.Configuration.Fields
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $sendusername
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $sendpassword
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
        .Update
    EndWith
    $objMessage.Send
    If @error Then MsgBox(48 + 262144, "COM Error", "@error is set to COM error number." & @CRLF & "@error = " & @error & @CRLF & "Error = " & $oMyError)
    If @error Then MyErrFunc()
    $oMyError = ""
    $objMessage = ""
EndFunc   ;==>mEmailer

In my function it simply calls MyErrFunc() with no arguements. What should I use for the arguement? The @Error or the $oMyError variable from the first line code:

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

Thank you for the help, and I am sorry for my lack of skill in this :(.

Link to post
Share on other sites

If you search the forum for this error message ("Transport failed to connect to the server") you will find some hits.

The problem may be caused by the configuration you use (smtpserver, SSL etc.)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Yeah, I appreciate the attention water, but I'm really at a loss here. it works fine for me on my computer, but my friends get errors. We are all three running the same operating system, one of the two doesnt run any security software at all, not even windows firewall. 

I am at a loss why it works fine and reliably with me and not them. I also had them both (just in case) install that microsoft package in case they didnt have outlook or anything with it. 

At this point I am very frustrated. All I need is a simple mail program, no attachments, just a TO, COPY, FROM, SUBJECT & MESSAGE. Think I am going to try something else, something a little more stable.

Link to post
Share on other sites

How about blat? Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usenet using NNTP.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

I've never used this script by Jos or any other SMTP script. I run MS Outlook to send mails.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

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

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

It doesn't matter what the server is running, it matters where the script is running. Gmail works with this UDF so Linux wouldn't be an issue.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

Quick question,
 
Can anyone explain why this does not work:

Global $SmtpServer = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "SmtpServer", Default)      ; address for the smtp-server to use - REQUIRED
Global $FromName = "MIERT: " & "Computer = " & @ComputerName & "Logon Name = " & @UserName      ; name from who the email was sent
Global $FromAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "FromAddress", Default)    ; address from where the mail should come
Global $ToAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "ToAddress", Default)        ; destination address of the email - REQUIRED
Global $Subject = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Subject", Default)            ; subject from the email - can be anything you want it to be
Global $Body                                                                    ; the messagebody from the mail - can be left blank but then you get a blank mail
Global $AttachFiles = @ScriptDir & IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "AttachFiles", Default)    ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed
Global $CcAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "CcAddress", Default)        ; address for cc - leave blank if not needed
Global $BccAddress = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "BccAddress", Default)      ; address for bcc - leave blank if not needed
Global $Importance = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Importance", Default)      ; Send message priority: "High", "Normal", "Low"
Global $Username = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Username", Default)          ; username for the account used from where the mail gets sent - REQUIRED
Global $Password = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "Password", Default)          ; password for the account used from where the mail gets sent - REQUIRED
Global $IPPort = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "IPPort", Default)              ; port used for sending the mail
Global $ssl = IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "ssl", Default)                    ; enables/disables secure socket layer sending - put to 1 if using httpS

If I hardcode the data into the script it works as in the OPs example:

$SmtpServer = "MailServer"              ; address for the smtp-server to use - REQUIRED
$FromName = "Name"                      ; name from who the email was sent
$FromAddress = "your@Email.Address.com" ; address from where the mail should come
$ToAddress = "your@Email.Address.com"   ; destination address of the email - REQUIRED
$Subject = "Userinfo"                   ; subject from the email - can be anything you want it to be
$Body = ""                              ; 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 = "******"                    ; 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 = 0                                ; enables/disables secure socket layer sending - put to 1 if using httpS

But if I try to read the data from an Ini file it is unable to connect to the server.
 
Again, the EXACT same data in the ini file hardcoded into the script works, but read from an ini does not...
 
any ideas?


EDIT: Answered by OP =

Global $IPPort = Number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "IPPort", Default))              ; port used for sending the mail
Global $ssl = Number(IniRead(@ScriptDir & "\Ctrl.ini", "emailinfo", "ssl", Default))                    ; enables/disables secure socket layer sending - put to 1 if using httpS
Edited by Wombat

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites

this one was made first, I posted it here so that others following this specific thread could learn from my mistake as well. I apologize

Just look at us.
Everything is backwards; everything is upside down. Doctors destroy health. Lawyers destroy justice. Universities destroy knowledge. Governments destroy freedom. The major media destroy information and religions destroy spirituality. ~ Michael Ellner


The internet is our one and only hope at a truly free world, do not let them take it from us...

Link to post
Share on other sites
  • 4 weeks later...

I would pop a message box to each read INI entry to make sure its correct all the way to the end.

in my case i needed to add @Scriptdir for each INI because attached files from other directories would change working directory effecting whole thing.

My question is:

Script works with Gmail but not with Yahoo or Live.

I get Error code:2  Description:The transport failed to connect to the server. for Live and Yahoo smtp servers

Any ideas on that ?

Pretty sure my login information is correct and smtp configurations too

Link to post
Share on other sites
  • Developers

The script works fine with Yahoo.... are you using the correct server/port/ssl info?

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 post
Share on other sites

The script works fine with Yahoo.... are you using the correct server/port/ssl info?

Jos

Live aka Outlook as well as Yahoo REQUIRED from address.

I didint provide it so it gave me errors.

Gmail could care less if there was no return email address :)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...