WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Examples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

MAIL COMPOSER SAMPLE

Keywords:  SMTPSendText	 

;**************************************************************************
;		 MAIL COMPOSER SAMPLE WINSOCK APP
;
; Usage: Run this file from WinBatch, optionally with 2 params:
;	 WILMail.WBT "<your dialup name>" "<your mail server>"
;
; Author: Jennifer Palonus (GDI)
; 
;  Date	   Major changes
; -------  ----------------------------------------------------------------
; 30mar96  Cloned from WILWeb.wbt.
; 04apr96  Implemented major functionality in SMTPSendText.
; 30apr96  
;**************************************************************************

sTitle = "SendMail"
sDial = ""
sMailServer = ""
sPort = "smtp"
sSigLine = "%@CRLF% %@CRLF%*** This msg sent to you via WILMail sample WinBatch script ***"


AddExtender ("wwwsk34I.dll")


; Get our mail server...
if (sMailServer == "")
	sMailServer = AskLine (sTitle, "Your mail server (ex.: mail.myhost.com)", "")
endif


;Dial our host, asking first if user has more than 1 defined...
hConn = 0
szDialUps = DUNItemize ()
if (ItemCount(szDialUps,@TAB) == 1)
	szDial = szDialUps
else
	szDial = AskItemList ("Choose a dial-up connection", szDialUps, @TAB, @SORTED, @SINGLE)
endif

hConn = DUNConnect (sDial)
nErr = wxGetLastErr()
if (!hConn)
	select (nErr)
		case @SErrBusy
			Message (sTitle, "Couldn't connect to %sDial%: Line busy.")
			break
		case @SErrNoAnswer
			Message (sTitle, "Couldn't connect to %sDial%: No answer.")
			break
		case @SErrVoice
			Message (sTitle, "Couldn't connect to %sDial%: A human answered.")
			break
		case nErr
			Message (sTitle, "Couldn't connect to %sDial%: Error %nErr%.")
	end select
	exit
endif


; Main command loop...
while (@TRUE) ;Till user hits Cancel...
	dlgMailFormat=`WWWDLGED,5.0`
	dlgMailCaption=`WILMail`
	dlgMailX=73
	dlgMailY=61
	dlgMailWidth=253
	dlgMailHeight=82
	dlgMailNumControls=10
	dlgMail01=`6,6,36,DEFAULT,STATICTEXT,DEFAULT,"From:"`
	dlgMail02=`42,6,198,DEFAULT,EDITBOX,edFrom,""`
	dlgMail03=`6,18,36,DEFAULT,STATICTEXT,DEFAULT,"To:"`
	dlgMail04=`42,18,198,DEFAULT,EDITBOX,edTo,""`
	dlgMail05=`6,30,36,DEFAULT,STATICTEXT,DEFAULT,"Subject:"`
	dlgMail06=`42,30,198,DEFAULT,EDITBOX,edSubject,""`
	dlgMail07=`6,42,36,DEFAULT,STATICTEXT,DEFAULT,"Text:"`
	dlgMail08=`42,42,198,DEFAULT,EDITBOX,edText,""`
	dlgMail09=`70,62,64,DEFAULT,PUSHBUTTON,DEFAULT,"Send",1`
	dlgMail10=`142,62,64,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",2`
	nDlgRet=Dialog("dlgMail")

	; Did user hit Cancel?...
	if (nDlgRet == 2)
		break
	endif

	; Add our signature line to user's text...
	sCmd = strcat(edText, sSigLine)

	; Send the mail...
	bOK = SMTPSendText (sMailServer, edFrom, edTo, edSubject, edText)
	if (bOK==@FALSE)
		nErr = wxGetLastErr ()
		Message (sTitle, "Error sending mail to %edTo% %@CRLF%    %nErr%")
	else
		Message (sTitle, "Mail sent to %edTo%.")
	endif
endwhile


; User hit Cancel...
:Cancel

; Hang up...
:HangUp
if (hConn)
	nRet = DUNDisconnect (hConn)
endif

exit

See Also: the Postie Extender.


Article ID:   W12639
Filename:   Send Mail with SMTPSendText.txt
File Created: 2001:03:01:15:12:08
Last Updated: 2001:03:01:15:12:08