Jump to content
Sign in to follow this  
allSystemsGo

Test Email with Blat

Recommended Posts

allSystemsGo

edit...solved..

Edited by zsutton92

Share this post


Link to post
Share on other sites
allSystemsGo

Nevermind...I figured it out...I left out the GuiCtrlRead portion...

Share this post


Link to post
Share on other sites
allSystemsGo

I think I have hit a wall here. This works on my computer...does not work anywhere else. I would like for it to work on any computer, since I will be testing this on customers' computers to check the functionality of the email server that runs along side our POS software. To send the email, it uses blat..so when I need to make sure the businesses are able to send it, I usually write a batch file. But I wrote this script to fancy it up a bit and to save some time.

Here is the script...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#AutoIt3Wrapper_Icon=..\..\Downloads\blattest.ico
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <Process.au3>
#include <zip.au3>






Global $hGUI,$hEdit,$hText,$iAttach,$iBody,$iEServer,$iFileAttach,$iFrom,$iInstall,$iPass,$iPort,$iSubject,$iTo,$iTry,$iUserName
checkBlat()
mainGUI()
Func mainGUI()
$hGUI=GUICreate("Testing with Blat",900,500,'','',-1)
GUICtrlCreateLabel("Install blat",25,25)
GUICtrlCreateLabel("Email Server",20,52)
$iEServer=GUICtrlCreateInput("",80,50,200)
GuiCtrlCreateLabel("User Name",20,82)
$iUserName=GuiCtrlCreateInput("",80,80,200)
GUICtrlCreateLabel("Password",20,115)
$iPass=GUICtrlCreateInput("",80,113,200)
GUICtrlCreateLabel("Try",350,52)
$iTry=GuiCtrlCreateInput("1",375,50)
GuiCtrlCreateLabel("Port",350,82)
$iPort=GUICtrlCreateInput("25",375,80)
$iInstall=GUICtrlCreateButton("Install Blat",350,113)
GUICtrlCreateLabel("Send an Email",25,155)
GuiCtrlCreateLabel("To:",20,185)
$iTo=GUICtrlCreateInput("",80,183,200)
GUICtrlCreateLabel("From:",20,215)
$iFrom=GUICtrlCreateInput("",80,213,200)
GUICtrlCreateLabel("Subject:",20,245)
$iSubject=GUICtrlCreateInput("",80,243,300)
GUICtrlCreateLabel("Body:",20,275)
$iBody=GUICtrlCreateInput("",80,273,300,100)
GUICtrlCreateLabel("NOTE:If the subject and/or body contain multiple characters, you must use quotations around the content!",80,477)

$aSendEmail=GUICtrlCreateButton("Send",345,425,50,50)
GUICtrlCreateLabel("Log",500,25)
$hEdit=GUICtrlCreateEdit('',500,45,375,415, _
BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL, $ES_NOHIDESEL))

GUICtrlSetData($hEdit,$hText)
GuiCtrlCreatePic(@ScriptDir&"\images\blat.jpg",5,450,75,50)
GUISetState()


While 1
$msg=GUIGetMsg()
Select
Case $msg=$GUI_Event_Close
ExitLoop
Case $msg= $iInstall
;MsgBox(64,@ScriptName,"Button Works!")
installBlat()
Case $msg= $aSendEmail
;MsgBox(64,@ScriptName,"Button Works!")
blat()
EndSelect
WEnd

EndFunc

Func installBlat()
$sEServer=GuiCtrlRead($iEServer)
$sUserName=GuiCtrlRead($iUserName)
$sTry=GuiCtrlRead($iTry)
$sPort=GuiCtrlRead($iPort)

_RunDos("blat.exe -install "&$sEServer&" "&$sUserName&" "&$sTry&" "&$sPort&" "&"-debug -log c:\temp\blat.log")
EndFunc

Func blat()
$sTo=GUICtrlRead($iTo)
$sFrom=GuiCtrlRead($iFrom)
$sEServer=GuiCtrlRead($iEServer)
$sUserName=GuiCtrlRead($iUserName)
$sPass=GuiCtrlRead($iPass)
$sSubject=GuiCtrlRead($iSubject)
$sBody=GuiCtrlRead($iBody)


_RunDos("blat.exe -to "& $sTo &" "&"-f "& $sFrom &" "&"-server "&$sEServer&" "&"-u "&$sUserName &" "&"-pw "& $sPass&" "& "-subject "& $sSubject &" "&"-body "& $sBody &" "& "-debug -log c:\temp\blat.log")
blatLog()
EndFunc

Func blatLog()
Global $file=FileOpen("c:\temp\blat.log")
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
$hText=FileRead($file)
FileClose($file)
GUICtrlSetData($hEdit,$hText)
EndFunc

Func checkBlat()
FileOpen("c:\temp\blat.log")
FileWrite("c:\temp\blat.log","begin")
FileClose("c:\temp\blat.log")
global $os_arch_type=@OSArch


If $os_arch_type='X64' Then
InetGet("http://downloads.sourceforge.net/project/blat/Blat%20Full%20Version/64%20bit%20versions/Blat%20v3.0.0/blat300_64.full.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fblat%2Ffiles%2FBlat%2520Full%2520Version%2F64%2520bit%2520versions%2FBlat%2520v3.0.0%2F&ts=1363289367&use_mirror=hivelocity",@UserProfileDir&"\blat300_64full.zip")
$fZipFile=@UserProfileDir&"\blat300_64full.zip"
$fDestPath=@UserProfileDir&"\blat300_64full"
_zip_unzipall($fZipFile,$fDestPath)
FileCopy(@UserProfileDir&"\blat300_64full\blat300\full\blat.dll",@UserProfileDir&"\blat.dll")
FileCopy(@UserProfileDir&"\blat300_64full\blat300\full\blat.exe",@UserProfileDir&"\blat.exe")
Else
InetGet("http://downloads.sourceforge.net/project/blat/Blat%20Full%20Version/32%20bit%20versions/Win2000%20and%20newer/blat311_32.full.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fblat%2Ffiles%2FBlat%2520Full%2520Version%2F32%2520bit%2520versions%2FWin2000%2520and%2520newer%2F&ts=1363289976&use_mirror=iweb",@UserProfileDir&"\blat311_32.zip")
$fZipFile=@UserProfileDir&"\blat311_32.zip"
$fDestPath=@UserProfileDir&"\blat311_32"
_zip_unzipall($fZipFile,$fDestPath)
FileCopy(@UserProfileDir&"\blat311_32\blat311\full\blat.dll",@UserProfileDir&"\blat.dll")
FileCopy(@UserProfileDir&"\blat311_32\blat311\full\blat.exe",@UserProfileDir&"\blat.exe")
EndIf
EndFunc

Like I said...works on my local machine, Windows 7 Pro 32bit. I test all of my scripts on my WinXP VM once I have it working locally. This script does not send the email on other machines, so I am guessing the _RunDOS() portion of the code is where there is a problem. Does not work on other Win7 machines either.

Thoughts? Advice?

Share this post


Link to post
Share on other sites
BrewManNH

You should probably specify the full path and file name to make sure that the script can find the exe file. Just to be on the safe side at the very least.


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

Share this post


Link to post
Share on other sites
allSystemsGo

My boss helped me figure this one out. Change all the

@UserProfileDir
to
@ScriptDir
, change the temp log to
@ScriptDir&"\blat.log"
, and we are good to go!

Edited by zsutton92

Share this post


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
Sign in to follow this  

×