To All
I have some code which derives its syntax from the TestSmtp example. I am using a Dialog box at the begining of my program before the main MDI window to determine if a User exists in the permissions table.
I give the user the option to add themselves to the table and upon successful addition to the table .. I want to send an SMTP e-mail to the application admin.
When I fire off this code and i get to the e-mail .. I get an alert that:
"You must create a Main window in order to use a Tsocket Object"
That is all well and fine .. but i am using the new Transparent clause and Transparent only seems to work for dialogs NOT windows.
Any Ideas here .. will the transparent clause work from a window and a redefine dialog from resources ?? It seems the transparent clause only works from code ?? In any rate, the SMTP mail is my most urgent problem.
Sorry for the attached code .. I have tried to condense it.
Rick Lipkin
SC Dept of Health, USA
//-------------------------------
IF xLOGIN = "UNKNOWN"
yLOGIN := WNetGetUser() // FiveWin function
yLOGIN := UPPER( yLOGIN )
oSAY := NIL
cSAY := NIL
cWELCOME := "WELCOME to the PMO Strategic Projects Vital Signs"
cSAY := "The System could not resolve your UserID "
cSAY1 := yLOGIN
cSAY2 := "You now have a choice to Add yourself as a"
cSAY3 := "Project Manager or enter the program Read Only?"
nOK := 0
DEFINE BRUSH oBru FILENAME ( cDEFA+"\PMO.BMP" )
DEFINE DIALOG oDLG1 ;
TITLE "WELCOME" ;
SIZE 700, 400 BRUSH oBRU TRANSPARENT
@ 0, 2 SAY cWELCOME OF oDlg1 COLOR "W+/W"
oDlg1:aControls[ 1 ]:lTransparent = .t.
@ 1, 2 SAY cSAY OF oDlg1 COLOR "W+/W"
oDlg1:aControls[ 2 ]:lTransparent = .t.
@ 1.5,2 SAY cSAY1 OF oDlg1 COLOR "W+/W"
oDlg1:aControls[ 3 ]:lTransparent = .t.
@ 2,2 SAY cSAY2 OF oDlg1 COLOR "W+/W"
oDlg1:aControls[ 4 ]:lTransparent = .t.
@ 2.5,2 SAY cSAY3 OF oDlg1 COLOR "W+/W"
oDlg1:aControls[ 5 ]:lTransparent = .t.
@ 50, 10 BTNBMP oBtn1 RESOURCE "YES" ;
SIZE 145, 15 OF oDlg1 ;
ACTION( oDlg1:End(), nOK := 1 )
oBtn1:lTransparent := .T.
@ 70, 10 BTNBMP oBtn2 RESOURCE "PMGR" ;
SIZE 145, 15 OF oDlg1;
ACTION( IF( _Addum( oDlg1 ),nOK := 4 , nOK := 2 ))
oBtn2:lTransparent := .T.
@ 90, 10 BTNBMP oBtn3 RESOURCE "CANCEL" ;
SIZE 145, 15 OF oDlg1 ;
ACTION( oDlg1:END(), nOK := 3)
oBtn3:lTransparent := .T.
ACTIVATE DIALOG oDlg1 CENTERED
DO CASE
CASE nOK = 1
xLOGIN := WNetGetUser() // FiveWin function
xLOGIN := UPPER( xLOGIN )
xLOGIN := xLOGIN+SPACE(8)
xLOGIN := SUBSTR(xLOGIN,1,8)
xREAD := 'Y'
xWRITE := 'N'
xPROJ := 'N'
xSUPER := 'N'
CASE nOK = 2
CLOSE DATABASES
RETURN(.F.)
CASE nOK = 4
// do nothing and proceed //
OTHERWISE
oDLG1:END()
CLOSE DATABASES
RETURN(.F.)
ENDCASE
ENDIF
// main mdi
...
...
//--------------------------
Static Func _AddUM( oDLG1 )
LOCAL oRsUser, cSQL, oERR, SAYING, oRsOwn
LOCAL cHOST, cUSEREID, cPMNAME, cPMEMAIL, cPMONAME, cPMOEMAIL
LOCAL oOutMail, cIP, cFROM, cTO, cSUBJECT, cMESSAGE
xLOGIN := WNetGetUser() // FiveWin function
xLOGIN := UPPER( xLOGIN )
xLOGIN := xLOGIN+SPACE(8)
xLOGIN := SUBSTR(xLOGIN,1,8)
SAYING := "WELCOME to the NEW Project Manager Add Routine"+chr(10)
IF MsgYesNo( saying )
ELSE
oDlg1:End()
RETURN(.F.)
ENDIF
// userview add routine
oRsuser := TOleAuto():New( "ADODB.Recordset" )
oRsuser:CursorType := 1 // opendkeyset
oRsuser:CursorLocation := 3 // local cache
oRsuser:LockType := 3 // lockoportunistic
cSQL := "SELECT * FROM USERINFO order by USERID"
TRY
oRsuser:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
MsgInfo( "Error in Opening USERINFO table" )
oDlg1:End()
RETURN(.F.)
END TRY
xREAD := 'Y'
xWRITE := 'N'
xPROJ := 'N'
xSUPER := 'N'
// double check for no dupes //
oRsuser:Find("USERID = '"+xLOGIN+"'" )
IF .not. oRsuser:eof
oRsUser:CLose()
SAYING := "SORRY ... "+xLOGIN+" already Exists in the User Table .. Aborting"
MsgInfo( saying )
oDlg1:End()
RETURN(.F.)
ENDIF
IF _UserView( "A", oRsUser, "login" )
xREAD := "Y"
xWRITE := oRsUser:Fields("write"):Value
xPROJ := oRsUser:Fields("mgr"):Value
xSUPER := oRsUser:Fields("super"):Value
xLOGIN := oRsUser:Fields("userid"):Value
cPMNAME := alltrim(oRsUser:Fields("name"):Value)
cPMEMAIL := alltrim(oRsUser:Fields("userid"):Value)+"@"+alltrim(oRsUser:Fields("domain"):Value)
// send mail from here
oRsOwn := TOleAuto():New( "ADODB.Recordset" )
oRsOwn:CursorType := 1 // opendkeyset
oRsOwn:CursorLocation := 3 // local cache
oRsOwn:LockType := 3 // lockoportunistic
cSQL := "SELECT * FROM OWNER"
TRY
oRSOwn:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
MsgInfo( "ERROR Opening Table OWNER to get E-mail parameters" )
oRsUser:CLose()
oDLG1:End()
RETURN(.T.)
END TRY
IF oRsOwn:eof
MsgInfo( "Sorry .. No Records for Table OWNER for E-mail" )
oRsUser:CLose()
oRsOwn:Close()
oDLG1:End()
RETURN(.T.)
ENDIF
cHOST := alltrim(oRsOwn:Fields("smtp_host"):Value)
cUSEREID := oRsOwn:Fields("usereid"):Value // get the pmo admin
oRsUser:MoveFirst()
oRsUser:Find("usereid = '"+cUSEREID+"'")
IF oRsUser:eof
cPMONAME := alltrim(oRsOwn:Fields("userid"):Value)+"@"+alltrim(oRsOwn:Fields("domain"):Value)
cPMOEMAIL := alltrim(oRsOwn:Fields("userid"):Value)+"@"+alltrim(oRsOwn:Fields("domain"):Value)
ELSE
cPMONAME := ALLTRIM(oRsUser:Fields("name"):Value)
cPMOEMAIL := alltrim(oRsUser:Fields("userid"):Value)+"@"+alltrim(oRsUser:Fields("domain"):Value)
ENDIF
oRsOwn:CLose()
oRsUser:CLose()
cFROM := "PMO Admin"
cTO := "LIPKINRM@DHEC.SC.GOV"
cSUBJECT := "Welcome New Project Manager"
cMESSAGE := "Test"
WSAStartup()
oOutMail := TSmtp():New( cIP := GetHostByName( cHOST ) )
* MsgInfo( cIP )
* oOutMail:bConnecting = { || MsgInfo( "Connecting to "+cHOST ) }
* oOutMail:bConnected = { || MsgInfo( "Connected" ) }
* oOutMail:bDone = { || MsgInfo( "Message sent successfully" ) }
oOutMail:SendMail( cFROM,; // From
{ cTO },; // To
cMESSAGE,; // message
cSUBJECT, ) // subject
oDLG1:End()
ELSE
oRsUser:CLose()
oDlg1:End()
RETURN(.F.)
ENDIF
RETURN(.T.)