Hi All,
OK, NWmedia and I figured out the work around with the winsock object and the user license issue. But, you will have to copy the MSWINSCK.OCX to the Windows\System or WinNT\System32 directory and the register it with the REGSRV32 on machines that don't have development software installed. That done, you can now inherit the properties of the winsock class in your executables. If you don't understand, don't worry about it. It makes my head hurt, too. Ok Here Goes:
First you have to create a class. For those who don't know how, Here's the step-by-step.
1.Select-<File> <New> and check the <Class> button.
2.The "CLASS" dialog window should be up.
3.Now let's fill in the <CLASS NAME> with WINSOCK.
4.In the <BASED ON> drop down select "OleControl".
5.Now fill in the <STORE IN>. Let's call it "C:\TESTCODE\CLASSLIB".
6.The "INSERT OBJECT" dialog window should be up. Under the "CHOOSE" selection, select "INSERT CONTROL".
7.Under the "CONTROL TYPE" select "MICROSOFT WINSOCK CONTROL, VERSION 6.0" and click <OK>.
8.Go ahead and close the "CLASS DESIGNER".
That's all for the Class. Now here is the revised sample program and SENDEMAIL() function. You will have to change the "mail.YourSMTPserver.com" in the function to your Email server.
*-------------------------------------------------------------------------------
* SendEmail Sample program
*-------------------------------------------------------------------------------
Set ClassLib to C:\TESTCODE\CLASSLIB.VCX
cEmailTo="JoeBlow@YourSMTPserver.com"
cEmailFrom="JoeBlow@YourSMTPserver.com"
cEmailSubject="TEST EMAIL"
cEmailBody = "This is only a TEST"
cEmailError = ""
If Not SendEmail(cEmailTo,cEmailFrom,cEmailSubject,cEmailBody,cEmailError)
Wait Window "Status Email Failed! Error= "+cEmailError Timeout 15
Endif
*-------------------------------------------------------------------------------
* SendEmail(cTo,cFrom,cSubject,cBody,@cErrorMsg)
* Description:
* Sends E-mail without the use of a configured E-mail Client.
*
* Environment:
*
* Parameters:
* cTo E-mail Address(s) to be sent to.
* For multiple E-mails separate with a ';'.
* Example: JDoe@acme.com;JQPublic@acme.com
* cFrom E-mail address or computer name of message originator.
* cSubject E-mail subject line to be sent
* cBody E-mail text message to be sent.
* cErrorMsg E-Mail dialog error message received from email Server
* (This is a string that must be defined outside of the
* function, initialized to "" and passed by "Reference"

*
* Results:
* .T. or .F.
*
* Remarks:
*
*-------------------------------------------------------------------------------
Function SendEmail(cTo,cFrom,cSubject,cBody,cErrorMsg)
Local oTCPIP, cSentData, aTo, cExact
Local nDataLen,nToSend,nError,lStatus
* Get the environment "Set Exact" Value
cExact = Set("Exact"

Set Exact on
* Load Locals
lStatus = .T.
cReceivedData = ""
nError = 0
* Do all Params have data?
If Empty(cTo) or Empty(cFrom) or ;
Empty(cSubject) or Empty(cBody)
*No, One or more Params is empty
cErrorMsg = "Not Enough Data Supplied Data to Send E-Mail!"
Wait Window cErrorMsg Time 10
lStatus = .F.
Else
* Parse out Email Address into Array
nToSend = Occurs(";", cTo) + 1
Dimension aTo(nToSend)
nPos1 = 1
For nX = 1 to nToSend
If nToSend = 1
aTo(nX) = cTo
Else
If nX = nToSend
aTo(nX) = Substr(cTo,nPos1)
Else
nPos2 = At(";", cTo, nX)
aTo(nX) = Substr(cTo,nPos1,nPos2-nPos1)
nPos1 = nPos2+1
Endif
Endif
Endfor
For nX = 1 to nToSend
* Set On Error For Error Trap of Object Creation
On Error nError = Error()
* Create Object
oTCPIP = CREATEOBJECT("form"

oTCPIP.NewObject("oleWinsock","Winsock"

* Did an Error Occur?
If nError = 0
* No Errors. Proceed!
On Error
* Connect to Mail.YourSMTPserver.Com
oTCPIP.oleWinsock.object.connect("mail.YourSMTPserver.com",25)
Do While oTCPIP.oleWinsock.object.RemoteHost = ""
Wait Window Chr(13)+Chr(10)+" Sending Email>......"+;
Chr(13)+Chr(10) Timeout .2
Enddo
* Did we Connect?
If oTCPIP.oleWinsock.object.SocketHandle > 0
Do While oTCPIP.oleWinsock.object.BytesReceived() < 4
Wait Window Chr(13)+Chr(10)+" Sending Email>>....."+;
Chr(13)+Chr(10) Timeout .2
Enddo
nDataLen = oTCPIP.oleWinsock.object.BytesReceived()
* Yes, we connected. Proceed!
oTCPIP.oleWinsock.object.GetData(@cReceivedData,nDataLen)
* Did we recieve the '220' from the server?
If Left(cReceivedData,3) = "220"
* Yes, start sending data to mail server!
oTCPIP.oleWinsock.object.SendData("mail from:<" + cFrom + ">"+;
Chr(13)+Chr(10))
Do While oTCPIP.oleWinsock.object.BytesReceived() < 4
Wait Window Chr(13)+Chr(10)+" Sending Email>>>...."+;
Chr(13)+Chr(10) Timeout .2
Enddo
nDataLen = oTCPIP.oleWinsock.object.BytesReceived()
oTCPIP.oleWinsock.object.GetData(@cReceivedData,nDataLen)
* Did the mail server accept the 'Mail From' Data?
If Left(cReceivedData,3) = "250"
* Yes, Proceed with Rcpt!
oTCPIP.oleWinsock.object.SendData("rcpt to:<" + aTo(nX) + ">"+;
Chr(13)+Chr(10))
Do While oTCPIP.oleWinsock.object.BytesReceived() < 4
Wait Window Chr(13)+Chr(10)+" Sending Email>>>>..."+;
Chr(13)+Chr(10) Timeout .2
Enddo
nDataLen = oTCPIP.oleWinsock.object.BytesReceived()
oTCPIP.oleWinsock.object.GetData(@cReceivedData,nDataLen)
* Did the mail server accept the 'Rcpt to' Data?
If Left(cReceivedData,3) = "250"
* Yes, Proceed with email body!
oTCPIP.oleWinsock.object.SendData("Data"+Chr(13)+Chr(10))
Do While oTCPIP.oleWinsock.object.BytesReceived() < 4
Wait Window Chr(13)+Chr(10)+" Sending Email>>>>>.."+;
Chr(13)+Chr(10) Timeout .2
Enddo
nDataLen = oTCPIP.oleWinsock.object.BytesReceived()
oTCPIP.oleWinsock.object.GetData(@cReceivedData,nDataLen)
* Is the email server ready for data?
If Left(cReceivedData,3) = "354"
* Yes, Send in data!
oTCPIP.oleWinsock.object.SendData("Subject: "+;
cSubject+Chr(13)+Chr(10) + ;
"From: " + cFrom +Chr(13)+Chr(10) + ;
"To: " + cTo +Chr(13)+Chr(10) + ;
+Chr(13)+Chr(10) + ;
cBody+Chr(13)+Chr(10) + ;
"."+Chr(13)+Chr(10))
Do While oTCPIP.oleWinsock.object.BytesReceived() < 4
Wait Window Chr(13)+Chr(10)+" Sending Email>>>>>>."+;
Chr(13)+Chr(10) Timeout 2
Enddo
nDataLen = oTCPIP.oleWinsock.object.BytesReceived()
oTCPIP.oleWinsock.object.GetData(@cReceivedData,nDataLen)
oTCPIP.oleWinsock.object.SendData("quit"+Chr(13)+Chr(10))
Else
* No. We didn't get a '354' back!
* Report Error and terminate.
cErrorMsg = cReceivedData
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Else
* No. We didn't get a '250' back!
* Report Error and terminate.
cErrorMsg = cReceivedData
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Else
* No. We didn't get a '250' back!
* Report Error and terminate.
cErrorMsg = cReceivedData
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Else
* No. We didn't get a '220' back!
* Report Error and terminate.
cErrorMsg = cReceivedData
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Else
* No, connection failed.
cErrorMsg = "Failed to Connect to E-Mail Server<Mail.YourSMTPserver.Com> on Port<25>!"
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Else
* Yes, Error Occurred. Couldn't create object.
On Error
cErrorMsg = Message()
Wait Window cErrorMsg Time 10
lStatus = .F.
Endif
Release oTCPIP
Endfor
Endif
* Reset the "Set Exact" value
Set Exact &cExact
* Return the Status Value
Return lStatus
EndFunc
***********************************************************************************
* END SendEmail()
***********************************************************************************
Now, this will work! Sorry it took so long to get back with an answer. Work can be such a bother! I had to save face and fix the problem. And save everyone $100 on a third party product that you don't need for simple email notification.
Good Luck. Have Fun!
Allen "Uncanny" Schott