ijourneaux Posted July 20, 2010 Share Posted July 20, 2010 (edited) Just realized that I should have posted here if I was looking for help. I have been using INetSmtpMailCOm successfully for a while but today, I bumped into an interesting problem. This is the typical call $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) In my case All of the paramaters are read in from an ini file. The key parameter is this case is $ssl. It is configured to be 0 in the ini file and I have confirmed that it is 0 prior to the call to _INetSmtpMailCom. Unfortunately when _INetSmtpMailCom is executed executed, it returns a COM error indicating that it can't connect to the SMTP server. If I make a single change and manually set $ssl=0 immediately prior to the call, _INetSmtpMailCom works as it should. What is different between setting $ssl to 0 explicitly to 0 and reading a 0 value from the ini file? Here is sample code that illustrates the problem. expandcollapse popup; ;################################## ; Include ;################################## #include <INetSmtpMailCom.au3> #include <file.au3> ;################################## ; Variables ;################################## ;################################## ; Variables ;################################## Global $SMTPServer Global $FromName Global $FromAddress Global $ToAddress Global $SMTPServer Global $Subject Global $Body Global $AttachFiles Global $CCAddress Global $BccAddress Global $Importance Global $Username Global $Password Global $IPPort Global $ssl ;################################## ; Script ;################################## readini() ; This call fails $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject & "Before" , $Body, "", $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) ; This one works $ssl = 0 $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject & "After" , $Body, "", $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) Func ReadIni() $SMTPServer = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "SMTPServer", "NotFound") $FromName = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "FromName", "NotFound") $FromAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "FromAddress", "NotFound") $ToAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "ToAddress", "NotFound") $Subject = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Subject", "NotFound") $Body = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Body", "NotFound") $CCAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "CCAddress", "NotFound") $BccAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "BccAddress", "NotFound") $Importance = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Importance", "NotFound") $Username = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Username", "NotFound") $Password = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Password", "NotFound") $IPPort = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "IPPort", "NotFound") $ssl = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "ssl", "NotFound") EndFunc Here is a sample INI file. It should be named IFMAutoReports.ini. I changed the addresses and servername [IFMAutoReports3D-PM16] SmtpServer = "relay.servername.net" FromName = "From" FromAddress = "from@address.com" ToAddress = "to@address.com" Subject = "Subject" Body = "The PDF file in this email is located in folder: " CcAddress = "cc@address.com" BccAddress = "" Importance = "Normal" Username = "" Password = "" IPPort=25 ssl=0 Edited July 20, 2010 by ijourneaux Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now