Hi. This is the class I am using to send emails. Maybe someone finds it useful:

**************************************************
*-- Class:        b_emailmgr (c:\dev\vfp\common\libs\b_emailmgr.vcx)
*-- ParentClass:  b_cst (c:\dev\vfp\common\libs\b_basevcx.vcx)
*-- BaseClass:    custom
*-- Time Stamp:   12/17/09 05:32:07 PM
*
DEFINE CLASS b_emailmgr AS Custom


        serveraddress = ""
        serverport = 25
        usessl = .F.
        *-- 0  = None; 1 - Basic (clear-text), 2 - NTLM
        authentication = 0
        serverusername = ""
        serverpassword = ""
        connectiontimeout = 60
        from = ""
        to = .F.
        cc = .F.
        bcc = .F.
        subject = .F.
        textbody = .F.
        htmlbody = .F.
        attachments = .F.

        *-- Occurs when the Valid event returns false (.F.), and provides a
means to display an error message.
        errormsg = .F.


        PROCEDURE send
                
**********************************************************************
                * Program....: B-Emailmgr.Send
                * Version....:
                * Author.....: Grigore Dolghin
                * Date.......: 31 October 2008, 12:32:58
                * Notice.....: Copyright © 2008, Class Software.
                * Compiler...: Visual FoxPro 09.00.0000.5815 for Windows
                * Abstract...:
                * Changes....: Grigore Dolghin, Created 31 October 2008 / 
12:32:58
                * Parameters.:
                * Called by..:
                * Purpose....: sends the message.
                
**********************************************************************
                Local ;
                        llSuccess As Boolean, ;
                        loMail As "CDO.Message", ;
                        loConfig As CDO.Configuration, ;
                        lnI As Integer

                With This
                        If ._CheckPrerequisites()
                                loMail = CreateObject("CDO.Message")
                                loConfig = loMail.Configuration

                                With loConfig As CDO.Configuration
                                        
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing";)
= 2
                                        
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";)
= This.ServerAddress
                                        
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport";)
= This.ServerPort
                                        
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl";)
= This.UseSSL
                                        
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout";)
= This.ConnectionTimeout
                                        If This.Authentication > 0
                                                
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate";)
= This.Authentication
                                                
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername";)
= This.Username
                                                
.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword";)
= This.ServerPassword
                                        EndIf
                                        .Fields.Update
                                EndWith

                                With loMail As CDO.Message
                                        .Sender = This.From
                                        .To = This.To
                                        .CC = This.CC
                                        .BCC = This.BCC
                                        .Subject = This.Subject
                                        .TextBody = This.TextBody
                                        If Not Empty(This.HTMLBody)
                                                .HTMLBody = This.HTMLBody
                                        EndIf

                                        For Each loFile In .Attachments
                                                loMail.AddAttachment(loFile)
                                        EndFor

                                        Try
                                                loMail.Send()
                                                llSuccess = .T.
                                        Catch To loError
                                                This.ErrorMsg = loError.Message
                                        Finally
                                                Release loMail
                                        EndTry
                                EndWith
                        EndIf
                EndWith
                Return llSuccess
        ENDPROC


        PROCEDURE addattachment
                
**********************************************************************
                * Program....: B-EmailMgr.AddAttachment
                * Version....:
                * Author.....: Grigore Dolghin
                * Date.......: 31 October 2008, 12:29:38
                * Notice.....: Copyright © 2008, Class Software.
                * Compiler...: Visual FoxPro 09.00.0000.5815 for Windows
                * Abstract...:
                * Changes....: Grigore Dolghin, Created 31 October 2008 / 
12:29:38
                * Parameters.:
                * Called by..:
                * Purpose....: Adds a file to the attachments collection.
                
**********************************************************************
                Lparameters tcFileName

                Local lnCounter As Integer

                With This
                        lnCounter = .Attachments.Count + 1
                        .Attachments.Add(tcFileName, Transform(lnCounter))
                EndWith
        ENDPROC


        PROCEDURE removeattachment
                
**********************************************************************
                * Program....: B-EmailMgr.RemoveAttachment
                * Version....:
                * Author.....: Grigore Dolghin
                * Date.......: 31 October 2008, 12:32:36
                * Notice.....: Copyright © 2008, Class Software.
                * Compiler...: Visual FoxPro 09.00.0000.5815 for Windows
                * Abstract...:
                * Changes....: Grigore Dolghin, Created 31 October 2008 / 
12:32:36
                * Parameters.:
                * Called by..:
                * Purpose....: Removes a file from attachments collection.
                
**********************************************************************
                Lparameters tnAttachmentIndex As Integer

                With This
                        If tnAttachmentIndex <= .Attachments.Count
                                .Attachments.Remove(tnAttachmentIndex)
                        EndIf
                EndWith
        ENDPROC


        PROTECTED PROCEDURE _checkprerequisites
                
**********************************************************************
                * Program....: B-EmailMgr._CheckPrerequisites
                * Version....:
                * Author.....: Grigore Dolghin
                * Date.......: 31 October 2008, 12:30:11
                * Notice.....: Copyright © 2008, Class Software.
                * Compiler...: Visual FoxPro 09.00.0000.5815 for Windows
                * Abstract...:
                * Changes....: Grigore Dolghin, Created 31 October 2008 / 
12:30:11
                * Parameters.:
                * Called by..:
                * Purpose....: Checks if all the prerequisites for email are 
satisfied.
                
**********************************************************************
                Local ;
                        llSuccess As Boolean, ;
                        lcFile As String

                llSuccess = .T.
                With This
                        If llSuccess And Empty(.ServerAddress)
                                .ErrorMsg = "No SMTP server specified."
                                llSuccess = .F.
                        EndIf
                        If llSuccess And .Authentication > 0
                                If llSuccess And Empty(.Username)
                                        .ErrorMsg = "No username specified."
                                        llSuccess = .F.
                                EndIf
                                If llSuccess And Empty(.ServerPassword)
                                        .ErrorMsg = "No password specified."
                                        llSuccess = .F.
                                EndIf
                        EndIf
                        If llSuccess And Empty(.From)
                                .ErrorMsg = "'From' field is empty."
                                llSuccess = .F.
                        EndIf
                        If llSuccess And Empty(.To)
                                .ErrorMsg = "'To' field is empty."
                                llSuccess = .F.
                        EndIf
                        If llSuccess
                                For Each oFile In .Attachments
                                        If Not File(oFile)
                                                .ErrorMsg = "File " + oFile + " 
cannot be found."
                                                llSuccess = .F.
                                                Exit
                                        EndIf
                                EndFor
                        EndIf

                        If llSuccess
                                .ErrorMsg = ""
                        EndIf
                EndWith

                Return llSuccess
        ENDPROC

        PROCEDURE Init
                         .Attachments = CreateObject("Collection")
        ENDPROC

ENDDEFINE
*
*-- EndDefine: b_emailmgr
**************************************************


On Wed, May 26, 2010 at 4:05 PM, Ted Roche <[email protected]> wrote:
>>
>> On Wed, May 26, 2010 at 11:01 AM, MB Software Solutions, LLC <
>> [email protected]> wrote:
>>
>>> Has anyone successfully configured BLAT to work for a gMail account?
>>>
>
> I don't think that's going to happen. Gmail requires TLS/SSL
> (http://lifehacker.com/111166/how-to-use-gmail-as-your-smtp-server)
> and BLAT isn't configured to support that. Other big providers like
> Yahoo! have the same kind of requirements.
>
> I'm sure there's some long and involved convoluted reason why you
> can't configure your app just to use the local ISP SMTP server. We've
> set up a couple apps using BLAT (or West Wind's IPTools) and we just
> supply an .INI file with settings that the client (or we) configure.
> Obviously, the idea has some problems scaling, supporting a couple
> hundred installations would be taxing.
>
> I've used GMail by configuring a local sendmail instance to use them
> as a smart host, but it involves a Linux box and setting up OpenSSL
> and downloading and configuring certificates. If you've got an app
> that you're sending out for wide distribution and you don't want to
> set up each and every client individually, you could considering
> renting a box/virtual server at your hosting provider of choice, and
> sending all of the mail from the clients to the mail server you host
> and configure. It's a non-trivial solution, but it leave you in
> control and could be set up for a few hundred dollars a year.
>
> Remember, "MAPI Bad, SMTP good" isn't just snarky, it's a statement of
> Best Practices. Using automation to Outlook, ActiveX Email,
> Collaborative Data Objects, or whatever, is just leaving your app at
> the mercy of the next MSFT service pack that decides to change the way
> it works or block a service as a security measure. Offloading
> fundamental network services to the standardized protocols and servers
> designed to run those services is using the Internet in the way it was
> intended.
>
> --
> Ted Roche
> Ted Roche & Associates, LLC
> http://www.tedroche.com
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to