[AccessD] Using BLAT as an Emailer

Stuart McLachlan stuart at lexacorp.com.pg
Thu Mar 4 19:06:28 CST 2010


Blat supports several form of AUTH and also POP3 login before send.
You just need to pass the Username/PW as parameters.



-- 
Stuart

On 4 Mar 2010 at 16:37, Rocky Smolin wrote:

> What about the authentication problem?
> 
> r 
> 
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
> Sent: Thursday, March 04, 2010 3:59 PM
> To: 'Access Developers discussion and problem solving'
> Subject: [AccessD] Using BLAT as an Emailer
> 
> 
> Hi Guys,
> 
> Here is an example of using BLAT as an Emailer.
> Replaces CDO, Redemption, docmd.SendObject, Outlook, ClickYes, etc, etc
> 
> FREE. I have used it in 32bit and this example was just used in 64bit so the
> program (blat) is pretty stable.
> Example is tested in A2k3
> Example is tested using a know smtp server with login details. I have not
> tried it in gmail. (yest)
> 
> Replace smtp login details with your own.
> 
> Max
> 
> 
> Option Compare Database
> Option Explicit
> ' Example by Max.Wanadoo at gmail.com
> ' Thanks to Stuart for helping to get the  batch call running correctly.
> 
> ' NOW:Forget  CDO.
> ' Forget Redemption
> ' Forget SendObject
> ' We have BLAT.
> ' Free and NO installation - just put a copy in your project folder and
> build some text files.
> 
> 
> ' Download Blat.zip from http://www.blat.net/ ' extract the contents and
> place them in your app folder (we only need the blat.exe but the rest will
> be worth reading.
> ' you can then create a FORM where the user can enter variables.  We will
> assume some constants,  but these can ' be variables as well.
> ' You can also store them in tables if  you wish (I would) ' This is just an
> exampls so that you understand how it works.
> ' full details of all the options are in the downloaded text files from
> blat.net
> 
> ' HERE are the contents of the text files used as examples. You can create
> these on the fly from within Access.
> 
> ' Subject.txt = "Hello World"
> ' Body.txt = This is a test email from Blat.
> ' Recipients.txt = max.wanadoo at gmail.com, max.wanadoo at gmail.com,
> max.wanadoo at gmail.com ' cc.txt = max.wandoo at gmail.com ' bcc.txt =
> max.wanadoo at gmail.com ' Signature.txt = Max, Manager ' ps.txt = PS. To
> unsubscribe send an email to helpmeplease at heaven.com
> 
> 
> Private sBlatFile, sBlatLog
> 
> Sub BlatExample()
> 'place these varibles in a form  for the user  to enter. We will just create
> them 'from here  to show how they fit together to make Blat work.
> ' What I have done is to put the contents of the various bits into external
> text files and call them with these ' variables but you can put them
> directly into the varible if you change the calling Blat Switch where
> required.
> ' See Blat file for documentation or drop me a line.  EG, -tf (to file)
> becomes -to (address list to send to) ' The files I have used are arbitarily
> named and I would antipate generting them from within Access where
> appropriate.
> 
>     If BlatCreate( _
>        sFrom:="me at mydomain.org", _
>        sRecipients:="Recipients.txt", _
>        sCC:="CC.txt", _
>        sBCC:="bcc.txt", _
>        sSubject:="subject.txt", _
>        sBody:="Body.txt", _
>        sSMTPServer:="smtp.mydomain.org", _
>        sSMTPUser:="me at mydomain.org", _
>        sSMTPPwd:="mysecretsmtppassword", _
>        sSignature:="Signature.txt", _
>        sPS:="ps.txt", _
>        sAttach:="Attach.txt") = 0 Then
>         Call sShell(sBlatFile)
>     End If
> End Sub
> 
> Function BlatCreate( _
>          sFrom As String, _
>          sRecipients As String, _
>          sCC As String, _
>          sBCC As String, _
>          sSubject As String, _
>          sBody As String, _
>          sSMTPServer As String, _
>          sSMTPUser As String, _
>          sSMTPPwd As String, _
>          sSignature As String, _
>          sPS As String, _
>          sAttach As String) As Long
>     On Error GoTo EH
> 
>     Dim sContents As String
>     sBlatFile = CurrentProject.Path & "\blat.bat"
>     sBlatLog = CurrentProject.Path & "\blat.log"
> 
>     sContents = "Blat.exe " & sBody & _
>               " -f " & sFrom & _
>               " -serverSMTP " & sSMTPServer & _
>               " -u " & sSMTPUser & _
>               " -pw " & sSMTPPwd & _
>               " -tf " & sRecipients & _
>               " -cf " & sCC & _
>               " -bf " & sBCC & _
>               " -sf " & sSubject & _
>               " -sig " & sSignature & _
>               " -ps " & sPS & _
>               " -attach " & sAttach
> 
>     ' That is  all the varibles, we will now put our constants in, but
>     ' if you want any of these to be changeable then just make them
> variables.
>     ' NB there are no cr/lf in this file.
>     ' this example asks for a read  receipt, etc.
>     
> 
>     sContents = sContents & " -noh2 -d -r -dsn sfd -priority 1 -log blat.log
> -timestamp -ti 60 -try 3 -hostname MyHostName"
> 
>     Close 1
>     On Error Resume Next
>     Kill sBlatFile
>     Kill sBlatLog
>     On Error GoTo EH
>     Open sBlatFile For Output As #1
>     Print #1, sContents
>     Close 1
> EX:
>     Close 1
>     Exit Function
> EH:
>     BlatCreate = Err.Number
>     Select Case BlatCreate
>     Case Else
>         MsgBox "Error: " & BlatCreate & vbCrLf & Err.Description
>     End Select
>     Resume EH
> End Function
> 
> Private Sub sShell(sFile)
>     Dim strCurPath As String, strCurDrive As String, strProjPath As String,
> strProjDrive As String
>     ' get the project location
>     strProjPath = CurrentProject.Path
>     strProjDrive = Left(strProjPath, 1):    'Debug.Print strProjDrive,
> strProjPath
> 
>     ' get the current location
>     strCurPath = CurDir
>     strCurDrive = Left(strCurPath, 1):    'Debug.Print strCurDrive,
> strCurPath
> 
>     ' change the current location to the project location
>     ' so that we can run the blat.exe via  the blat.bat file
>     ChDrive strProjDrive
>     ChDir strProjPath
> 
>     ' now run the batch file
>     Shell sFile
> 
>     ' now restore the current location back to what it was.
>     ChDrive strCurDrive
>     ChDir strCurPath
> End Sub
> 
> 
> 
> 
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com





More information about the AccessD mailing list