Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Communicating from customer apps back to us
Message
 
To
26/11/2008 11:13:59
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01364192
Message ID:
01364225
Views:
44
>>>We have a need to receive error reports (either a table or text files) from all of our apps that are out in the field back to our home office. These are a couple of scenarios and questions I have regarding that.
>>>
>>>Email: What if the client does not have Outlook installed (some don't). What if they are using an email other than Outlook. Or don't use client email?
>>>
>>>Web Service: I now know how to communicate to a server, but what needs to be done on the server to accept the request/information?
>>>
>>>FTP: Have no idea how to implement this from either side.
>>
>>Take a look at incorporating Blat into your app to send what you need. It's very simple to use, is free, and works great. It runs straight from your program so doesn't require Outlook. I implemented it at my last client (on Bill Kuhn's recommendation) and it was a big hit.
>
>That looked promising but I ran into a bunch of broken links,etc. Couldn't get the DLL. They almost have too much information to be useful on the Blat site. Do you have any Foxpro code kicking around that uses Blat?

Let's see if this makes it - It checks and sets BLAT keys in the registry - you may not need that - if you do I can send you the registry class that is used as well..
DEFINE CLASS sendblatmail as custom
************************************

#IF .F.
	LOCAL this as sendblatmail OF blatmail.prg
#ENDIF

	icBlatDllFolder = <folderwheretheDLLisslocated>  && MODIFY THIS!!
	icFrom = ''
	icTo = ''
	icCC = ''
	icBCC = ''
	icSubject = ''
	inReturnCode = 0
	icErrorMessage = ''
	icBodyFile = ''
	icMessageString = ''
	ilSendTheString = .F.
	ilSendTheFile = .F.
	icFiletoAttach = ''

	&& the following are entered in registry if BLAT installation info not found

	icSMTP_Server = 'mail.mySMTPServer.com'  && MODIFY THIS
	icSender = 'myUserName@mydomain.com'     && MODIFY THIS
	icTry = '2'
	icSMTP_Port = '25'
	
*********************************************************
	FUNCTION init(tcBlatDllFolder,tcFrom,tlSendTheString)
*********************************************************
	LOCAL lcBlatDllFile
	
	IF !EMPTY(tcBlatDllFolder)
		this.icBlatDllFolder = ADDBS(TRIM(tcBlatDllFolder))
	ENDIF
	
	IF !EMPTY(tcFrom)
		this.icFrom = TRIM(tcFrom)
	endif
	
	IF EMPTY(tlSendTheString)
		this.ilSendTheString = .F.
		this.ilSendTheFile = .T.
	ELSE
		this.ilSendTheString = tlSendTheString
		this.ilSendTheFile = !tlSendTheString
	ENDIF
	
	lcBlatDllFile = ADDBS(TRIM(this.icBLATDLLFOLDER))+"BLAT.DLL"
	
	IF !FILE(lcBlatDLLFile)
		RETURN .F.
	ENDIF
	
	CLEAR DLLS Send
	
        && I have this verify all the BLAT registry items exist - if not, it sets them so no blat config is needed - 
	this.CheckRegistry()

	DECLARE INTEGER Send in &lcBlatDllFile STRING blatstring
	
*********************************************************		
	ENDFUNC && INIT
*********************************************************	

*********************************************************
	FUNCTION CheckRegistry()
*********************************************************	

	LOCAL OReg
	
	oReg = .NULL.
	
	oReg = NEWOBJECT("registryinterface","registryinterface.prg")
	
	&& Check for required keys - if not found, set!
	
	IF LEFT(oReg.check_registry_value("SMTP Server","software\Examinetics\NewDG\Blat"),4) = 'KGNO'
		oReg.set_registry_value("SMTP Server",this.icSMTP_SERVER,"software\Public Domain\Blat")
	endif

	IF LEFT(oReg.check_registry_value("SMTP Port","software\Examinetics\NewDG\Blat"),4) = 'KGNO'
		oReg.set_registry_value("SMTP Port",this.icSMTP_PORT,"software\Public Domain\Blat")
	endif

	IF LEFT(oReg.check_registry_value("Try","software\Examinetics\NewDG\Blat"),4) = 'KGNO'
		oReg.set_registry_value("Try",this.icTRY,"software\Public Domain\Blat")
	endif

*!*		IF LEFT(oReg.check_registry_value("Sender","software\Examinetics\NewDG\Blat"),4) = 'KGNO'
		oReg.set_registry_value("Sender",this.icSENDER,"software\Public Domain\Blat")
*!*		ENDIF
	
	RELEASE oReg
	
	RETURN .T.

*********************************************************
	ENDFUNC  && CHECKREGISTRY
*********************************************************	

*********************************************************		
	FUNCTION send(tcTo,tcCC,tcBCC,tcSubject,tcMessageString,tcBodyFile,tlSendTheString,tcFileToAttach,tcFrom)
*********************************************************		
	
	LOCAL llRetVal
	LOCAL lcBlatCommandString
	LOCAL lnResult
	
	
	IF EMPTY(tcTo) AND EMPTY(this.icTO)  && nowhere to send!
		this.inReturnCode = -1
		this.icErrorMessage = 'TO is not specified!'
		RETURN .F.
	ELSE
		IF !EMPTY(tcto)
			this.icto = ALLTRIM(tcTo)
		endif
	endif
	
	IF !EMPTY(tcCC)
		this.icCC = tcCC
	ENDIF
	
	IF !EMPTY(tcBCC)
		this.icBCC = tcBCC
	endif
	
	IF !EMPTY(tcSubject)
		this.icSubject = TRIM(tcSubject)
	ENDIF
	
	IF !EMPTY(tcMessageString)
		this.icMessageString = TRIM(tcMessageString)
	endif
	
	IF !EMPTY(tcBodyFile)
	
		this.icBodyFile = allTRIM(tcBodyFile)
		
		IF !FILE(tcBodyFile)
			this.inReturnCode = -1
			this.icErrorMessage = 'Message Body File "' + tcBodyFile + '" does not exist!'
			RETURN .f.
		ENDIF

	ENDIF
	
	IF !EMPTY(tlSendTheString)
		this.ilSendtheString = tlSendTheString
		this.ilSendTheFile = !tlSendTheString
	endif
	
	IF !EMPTY(tcFileToAttach)

*!*			IF FILE(tcFileToAttach)
			this.icFileToAttach = tcFileToAttach
*!*			ELSE
*!*				this.icErrorMessage = IIF(!EMPTY(this.icErrorMessage),this.icErrorMessage+' :: ' + 'File to attach "' + tcFileToAttach + '" was not found!','File to attach "' + tcFileToAttach + '" was not found!')		
*!*			endif
	
	endif
	
	lcBlatCommandString = ''
	lnResult = 0
	llRetVal = .F.

	
	&& build the string
	lcBlatCommandString = IIF(this.ilsenDTHEFILE,this.icBODYFILE+' ','NUL ') 
	lcBlatCommandString = lcBlatCommandString + IIF(!EMPTY(this.icTO),'-to '+this.icTO + ' ','')
	lcBlatCommandString = lcBlatCommandString + IIF(!EMPTY(this.icCC),'-cc '+this.icCC+' ','')
	lcBlatCommandString = lcBlatCommandString + IIF(!EMPTY(this.icBCC),'-bcc '+this.icBCC + ' ','')
	lcBlatCommandString = lcBlatCommandString + '-f '+ IIF(!EMPTY(tcFrom),tcFrom,this.icFrom) + ' '
	lcBlatCommandString = lcBlatCommandString + IIF(!EMPTY(this.icsUBJECT),'-s "'+this.icSUBJECT +'" ','')
	lcBlatCommandString = lcBlatCommandString + IIF(this.ilsendthestring,'-body "'+this.icmessagestring+'" ','')
	lcBlatCommandString = lcBlatCommandString + IIF(!EMPTY(this.icFileToAttach),'-attach '+ this.icFileToAttach,'')	
	
	WAIT 'Sending mail to '+this.icTo+IIF(!EMPTY(this.iccc),'+ '+this.iccc,'') +IIF(!EMPTY(this.icbcc),'+ '+this.icbcc,'') + '..' WINDOW nowait
	
	lnResult = Send(lcBlatCommandString)
	
	WAIT clear
	IF lnResult = 0
	
		llRetVal = .T.

		this.icFrom = ''
		this.icTo = ''
		this.icCC = ''
		this.icBCC = ''
		this.icSubject = ''
		this.icErrorMessage = ''
		this.icBodyFile = ''
		this.icMessageString = ''
		this.ilSendTheString = .F.
		this.ilSendTheFile = .F.
		this.icFiletoAttach = ''
			
	ELSE
		this.inReturnCode = lnResult
		lRetVal = .F.
	endif
	
	
	RETURN llRetVal
	
*********************************************************		
	ENDFUNC  && send
*********************************************************		

*********************************************************		
	FUNCTION DESTROY
*********************************************************		

			CLEAR DLLS Send

*********************************************************		
	ENDFUNC  && DESTROY
*********************************************************		
	
*********************************************************		
ENDDEFINE  && class sendblatmail
*********************************************************		
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Previous
Reply
Map
View

Click here to load this message in the networking platform