dh262 Posted September 25, 2007 Share Posted September 25, 2007 Is is possible to route e-mail from DAQFactory express through a mail server that requires TLS/SSL? Or will I need to find an alternative method, such as using the labjack python libraries and writing my own script? Link to comment Share on other sites More sharing options...
AzeoTech Posted September 25, 2007 Share Posted September 25, 2007 No not at present. My recommendation, unless you enjoy the challenge of writing python, is to get a free email account that doesn't require SSL. I know gmail does require it, but I believe yahoo and others don't. You could always then forward that mail through your normal SSL, or simply set the reply to address to something else. Link to comment Share on other sites More sharing options...
azeotechandy Posted March 10, 2009 Share Posted March 10, 2009 Solving Azeotech's Daqfactory email SSL bug ... Problem solved !!!! For gmail & att/yahoo users which require SSL for email. You be surprised on how many IP cameras and software programs that cannot do secure socket email. Step #1 Goto Link and download the FREE AutoIt windows scripting software. http://www.autoitscript.com/autoit3/ Step #2 Install the software on the PC. Step #3 Cut and paste the following code into the editor and after filling in the email information make it into a exe. For testing, send an email to yourself and just doubleclick on the compiled script exe icon. Then run the exe from your sequence program in DaqFactory. Note: The nice part is a person can edit this email information externally from Daqfactory and compile it into a exe for executing from Daqfactory. ------------------------------------------------------- Code sample #1 -------------------------------------------------------------- ; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $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 you want to attach- 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 ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $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 ; ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF);### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc ------------------------------------------------------------- OR Code sample #2 - Do not use both ------------------------------------------------------------- #NoTrayIcon #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=SMS.ico #AutoIt3Wrapper_outfile=SMS.exe #AutoIt3Wrapper_Res_Comment=By: Isaac Flaum #AutoIt3Wrapper_Res_Description=Allows computer to send SMS messages to phones #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Isaac Flaum 2008 #AutoIt3Wrapper_Res_Language=1033 #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiScrollBars.au3> #include<file.au3> #include<misc.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #include <EditConstants.au3> $s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED $s_FromName = ""; name from who the email was sent $s_FromAddress = ""; address from where the mail should come $s_ToAddress = ""; destination address of the email - REQUIRED $s_Subject = ""; subject from the email - can be anything you want it to be $as_Body = ""; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = ""; the file you want to attach- leave blank if not needed $s_CcAddress = ""; address for cc - leave blank if not needed $s_BccAddress = ""; address for bcc - leave blank if not needed $s_Username = ""; username for the account used from where the mail gets sent - Optional (Needed for eg GMail) $s_Password = ""; password for the account used from where the mail gets sent - Optional (Needed for eg GMail) $IPPort = 465; port used for sending the mail $ssl = 1; enables/disables secure socket layer sending - put to 1 if using httpS Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") GUICreate("SMS", 160, 180) $send = GUICtrlCreateButton("Send", 5, 150, 150, 25) $phonenum = GUICtrlCreateLabel("Phone Number:", 5, 5, 80, 20) $phonesubject = Guictrlcreatelabel("Subject:", 5, 30, 80, 20) $subject = guictrlcreateinput("", 50, 30, 105, 20) guictrlsetstate(-1, $GUI_DISABLE) $to = GUICtrlCreateInput("", 85, 5, 70, 20) $attatchment = GUICtrlCreateButton("Attatchment", 5, 55, 80, 20) $carrier = GUICtrlCreateCombo("Carrier", 90, 55, 65, 20) GUICtrlSetData(-1, "Verizon|AT&T|Sprint|T-Mobile", "Carrier") $numchar = GUICtrlCreateLabel("Characters Left: 160", 5, 130, 100, 20) $txt = GUICtrlCreateEdit("", 5, 85, 150, 40, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) guisetbkcolor(0x99cc66) GUISetState(@SW_SHOW) While 1 sleep(10) $msg = GUIGetMsg() $readtxt = GUICtrlRead($txt) $length = StringLen($readtxt) $actualchar = Execute(160 - $length) GUICtrlSetData($numchar, "Characters Left: " & $actualchar) Select Case ($msg = $attatchment) $s_AttachFiles = FileOpenDialog("Attatchment", @DesktopDir, "Files (*.mid;*.gif;*.jpg;*.mp3)") guictrlsetstate($subject, $GUI_ENABLE) Case ($msg = -3) Exit Case ($msg = $send) $s_Subject = guictrlread($subject) $as_Body = GUICtrlRead($txt) $s_ToAddress = GUICtrlRead($to) $wacarrier = GUICtrlRead($carrier) Select Case ($wacarrier = "Verizon") If $s_AttachFiles = "" Then $s_ToAddress = $s_ToAddress & "@vtext.com" Else $s_ToAddress = $s_ToAddress & "@vzwpix.com" EndIf Case ($wacarrier = "AT&T") If $s_AttachFiles = "" Then $s_ToAddress = $s_ToAddress & "@txt.att.net" Else $s_ToAddress = $s_ToAddress & "@mobile.att.net" EndIf Case ($wacarrier = "Sprint") If $s_AttachFiles = "" Then $s_ToAddress = $s_ToAddress & "@messaging.sprintpcs.com" Else $s_ToAddress = $s_ToAddress & "@messaging.sprintpcs.com" EndIf Case ($wacarrier = "T-Mobile") If $s_AttachFiles = "" Then $s_ToAddress = $s_ToAddress & "@tmomail.net" Else $s_ToAddress = $s_ToAddress & "@tmomail.net" EndIf EndSelect $sendprog = ProgressOn("Sending", "Sending Message...") $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc) EndIf EndSelect WEnd Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) ProgressSet(10) $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' ProgressSet(20) $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" ProgressSet(30) If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) Return 0 EndIf Next EndIf ProgressSet(40) $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ProgressSet(60) ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ProgressSet(80) ;Update settings $objEmail.Configuration.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf ProgressSet(100) ProgressOff() EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler -------------------------------------------------------- Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.