A tool to send email ?

User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

A tool to send email ?

Post by Armando »

Hi friends:

Do you know a very good class, function, lib, dll or tool to send emails from my app, my tools: FWH0810 and xHarbour build 1.1.0 Intl. (SimpLex) (Rev. 6195)?

With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: A tool to send email ?

Post by Armando »

Thanks a lot Enrico.

Is it possible a small sample :oops:

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A tool to send email ?

Post by Enrico Maria Giordano »

Here it is:

Code: Select all

#include "Fivewin.ch"


STATIC hLib


FUNCTION MAIN()

    LOCAL cFrom     := ""
    LOCAL cServer   := ""
    LOCAL cTo       := ""
    LOCAL cSubjeCt  := ""
    LOCAL cMessage  := ""
    LOCAL cSender   := ""
    LOCAL cUser     := ""
    LOCAL cPassword := ""

    ? SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, , cSender, cUser, cPassword )

    RETURN NIL


FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort, lNotification )

    LOCAL cMsgFile := CTEMPFILE()

    LOCAL cCmd := "SndMail -f " + cFrom + " -X " + cServer + " -r " + cTo + " -s " + ["] + cSubject + ["] + " -b " + cMsgFile

    LOCAL nRes

    LOCAL i

    DEFAULT lHtml := "<html" $ LOWER( cMessage )

    MEMOWRIT( cMsgFile, cMessage + CRLF )

    IF !EMPTY( aAttach )
        FOR i = 1 TO LEN( aAttach )
            cCmd += " -a " + ["] + aAttach[ i ] + ["]
        NEXT
    ENDIF

    IF !EMPTY( cSender )
        cCmd += " -F " + ["] + cSender + ["]
    ENDIF

    IF !EMPTY( cUser )
        cCmd += " -h LOGIN -u " + cUser
    ENDIF

    IF !EMPTY( cPassword )
        cCmd += " -p " + cPassword
    ENDIF

    IF !EMPTY( aCc )
        FOR i = 1 TO LEN( aCc )
            cCmd += " -c " + ["] + aCc[ i ] + ["]
        NEXT
    ENDIF

    IF lHtml
        cCmd += " -H"
    ENDIF

    IF !EMPTY( cPort )
        cCmd += " -P " + cPort
    ENDIF

    IF !EMPTY( lNotification )
        cCmd += " -t " + ["] + "Disposition-Notification-To: " + cFrom + ["]
    ENDIF

    hDLL = LOADLIBRARY( "sndmail.dll" )

    SMTPLIBOPEN()

    nRes = SMTPSENDMAIL( cCmd )

    SMTPLIBCLOSE()

    FREELIBRARY( hDLL )

    FERASE( cMsgFile )

    RETURN nRes = 0


DLL STATIC FUNCTION SMTPLIBOPEN() AS VOID;
    PASCAL FROM "USmtpLibOpen" LIB hLib

DLL STATIC FUNCTION SMTPSENDMAIL( cCmd AS STRING ) AS LONG;
    PASCAL FROM "USmtpCmdLineSendMail" LIB hLib

DLL STATIC FUNCTION SMTPLIBCLOSE() AS VOID;
    PASCAL FROM "USmtpLibClose" LIB hLib
EMG
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: A tool to send email ?

Post by Armando »

Enrico:

Thanks so much for your sample, I'll test it.

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Baxajaun
Posts: 853
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: A tool to send email ?

Post by Baxajaun »

Enrico,

thanks a lot for the sample and your help !!!

Armando,

change hDLL for hLib.

Best regards,

Felix
User avatar
Willi Quintana
Posts: 859
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Re: A tool to send email ?

Post by Willi Quintana »

Hi friends...

came out this error when compiling

Error: 'D:\SOFT\SNDMAIL\SNDMAIL-2.5\SNDMAIL.LIB' contains invalid OMF record,
User avatar
Willi Quintana
Posts: 859
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Re: A tool to send email ?

Post by Willi Quintana »

Hi,,, (thanks Giordano)
any example with hotmail???
this is my code:

Code: Select all

 cFrom     := "cliente@hotmail.com"
 cServer   := "smtp.live.com"
 cTo       := "willi@hotmail.com"
 cSubject  := "error system"
 cMessage  := memoread("error.log")
 cSender   := ""
 cUserm    := "cliente"
 cPassm    := "12345678"
 ? SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, , cSender, cUserm, cPassm )
 
return .F.

suggestions??
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A tool to send email ?

Post by Enrico Maria Giordano »

Willi Quintana wrote:Hi,,, (thanks Giordano)
My name is Enrico. :-)
Willi Quintana wrote:any example with hotmail???
No, sorry. It should work. Does it work using Outlook or similar email apps?

EMG
zazibr
Posts: 71
Joined: Mon Jan 28, 2008 11:18 am
Location: Campo Grande,MS, BRASIL

Re: A tool to send email ?

Post by zazibr »

hotmail

-P port Set SMTP port { 25 }

port 25 or 995
Daniel Lopes Filho - Campo Grande,MS,Brasil
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6693) + gtwvw + fw 10.2 + vsx e
fw pcc (ainda não usei)
msn : zazibr@hotmail.com
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: A tool to send email ?

Post by ukoenig »

Enrico,

I tested Your sample, but nothing happens

FUNCTION MAIN()
// AOL SMTP-Server ( infos from internet ):
// smtp.de.aol.com for emails ending with aol.com
// login for the SMTP-Server is needed.
// username and password

LOCAL cFrom := "Uwe"
LOCAL cServer := "smtp.de.aol.com"
LOCAL cTo := "esckoenig@aol.com" // my email for testing the mailbox for incomming emails
LOCAL cSubjeCt := "Test"
LOCAL cMessage := "Test"
LOCAL cSender := "Uwe"
LOCAL cUser := "aoluser" // adding my username
LOCAL cPassword := "aolpassword" // adding my password

? SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, , cSender, cUser, cPassword )

RETURN NIL
FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort, lNotification )
...
...


maybe something missing or not possible to use it ?
or is there maybe another working sample in the meantime
because the post is dated 2011 ?

regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: A tool to send email ?

Post by Enrico Maria Giordano »

I don't use sndmail.dll any longer. Now I'm using CDO.Message:

Code: Select all

FUNCTION SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort, lNotification, lSSL )

    LOCAL lOk := .F.

    LOCAL oCfg, oMsg

    LOCAL cCc := ""

    LOCAL i

    DEFAULT lHtml         := "<html" $ LOWER( cMessage )
    DEFAULT lNotification := .F.
    DEFAULT lSSL          := .F.

    TRY
        oCfg = CREATEOBJECT( "CDO.Configuration" )

        oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value = cServer

        IF !EMPTY( cPort )
            oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := VAL( cPort )
        ENDIF

        oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value = 2
        oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .F.

        IF !EMPTY( cUser ) .AND. !EMPTY( cPassword )
            oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value = .T.
            oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value = cUser
            oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPassword
            oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value = lSSL
        ENDIF

        oCfg:Update()

        oMsg = CREATEOBJECT( "CDO.Message" )

        oMsg:Configuration = oCfg

        IF !EMPTY( cSender )
            cFrom = ["] + cSender + ["] + " <" + cFrom + ">"
        ENDIF

        oMsg:From    = cFrom
        oMsg:To      = cTo
        oMsg:Subject = cSubject

        IF !EMPTY( aCc )
            FOR i = 1 TO LEN( aCc )
                IF i > 1
                    cCc += ";"
                ENDIF

                cCc += aCc[ i ]
            NEXT

            oMsg:CC = cCc
        ENDIF

        IF !lHtml
            oMsg:TextBody = cMessage
        ELSE
            oMsg:HTMLBody = cMessage
        ENDIF

        IF !EMPTY( aAttach )
            FOR i = 1 TO LEN( aAttach )
                oMsg:AddAttachment( aAttach[ i ] )
            NEXT
        ENDIF

        IF lNotification
            oMsg:Fields:Item( "urn:schemas:mailheader:disposition-notification-to" ):Value = cFrom
            oMsg:Fields:Update()
        ENDIF

        oMsg:Send()

        lOk = .T.
    CATCH
    END

    RETURN lOk
EMG
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: A tool to send email ?

Post by ukoenig »

Enrico,

thank You very much for the sample.
I will add it to my downloadsection and test it

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply