Frequently
Asked
Questions


Poll

Which Web server are you using with Active FoxPro Pages?
 


Navigation

Active FoxPro Pages FAQ
AFP 2.x
AFP in general
First steps
News
Plugins
Resources
Samples
Votes
Web server
FAQuarium
Glossary
Plugins
Server
Sidebar
Site Navigation Bar
Top Articles


Your Location

Germany


Partner Sites

- Microsoft Community Guide -
- AFPBB Boost your Board -
- AFP-Community -
- MiDeK - Internet Publishing -
- VfpNetwork.Com -
- MSDN VFP -
- CoDe Magazine -
- Golo Haas -


Advertisement

Imprint

Microsoft CLIP member

 
  [186] Use BLAT to send mails with Active FoxPro Pages
Rate this page Print Office Email Discuss
465 requests - last updated Montag, 14.03.2005

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

All text is available under the terms of the
GNU Free Documentation License.

User contributed notesAdd a note
Copyright © 2002-2005 AFP FAQ. All rights reserved. Please send any irritations on this Web site to our Webmaster. Validate HTML