As stated in another FAQ article about How to send e-mails with Active FoxPro Pages it is possible to use BLAT to send emails. This article describes its usage with Active FoxPro Pages.
Sometimes, adcSendMail doesn't work with all mail server. Alternatively, you
can try the following code that uses BLAT.DLL. Before you run the code,
please
- Download BLAT.DLL from the specified URL and put it into the AFP directory
(C:\Program Files\AFP3 by default).
- Change the variables in the first section according to your mail adresses
and SMTP server
<%
* Send E-Mail using BLAT (http://www.geocities.com/toby_korn/blat/)
* Parameter. Change as needed
Local lcBody, lcSubject, lcTo, lcFrom, lcServer, lcUser, lcPassword
lcBody = "This is the body."
lcSubject = "Hello world"
lcTo = "faqarticle@prolib.de"
lcFrom = "faq@afpfaq.de"
lcServer = "www.afpfaq.de"
lcUser = "faq"
lcPassword = "secret"
* Load DLL
Local lcDLL
lcDLL = Path.MakePath("%root%\Blat.DLL")
If not file(m.lcDLL)
? "DLL cannot be found"
Return
EndIf
Declare Long Send in (m.lcDLL) String
* Write body text into a temporary file
Local lcFile
lcFile = addbs(getenv("temp"))+"tmp_"+Sys(3)+".Txt"
StrToFile( m.lcBody, m.lcFile )
* Build parameter string
Local lcBLAT
lcBLAT = [ -s "] + m.lcSubject + ;
[" -to ] + m.lcTo + ;
[ -from ] + m.lcFrom + ;
[ -replyto ] + m.lcFrom
* Check for HTML format
If Left(Chrtran(m.lcBody," "+Chr(9)+Chr(13)+Chr(10),""),1) == "<" ;
and Right(Chrtran(m.lcBody," "+Chr(9)+Chr(13)+Chr(10),""),1) == ">"
BLAT = m.BLAT + " -html"
EndIf
* Send e-mail
Local lnOK
lnOK = Send( ;
m.lcFile + m.lcBLAT + " -mailfrom " + m.lcFrom + ;
[ -server ]+m.lcServer+[ -port 25 -u "]+m.lcUser+[" -pw
"]+m.lcPassWord+["] ;
)
* Erase file
If File(m.lcFile)
Erase (m.lcFile)
EndIf
* Status
If m.lnOK == 0
? "OK"
Else
? "Error " + Transform(m.lnOK)
Endif
%>
The code above describes usage of BLAT very detailed.
If you are using an alternative to BLAT, please drop me some lines at my post-office: faq@afpfaq.de - Thanks!
Enjoy the AFP FAQ, JoKi