A tool to send email ?

A tool to send email ?

Postby Armando » Fri May 06, 2011 5:11 pm

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: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Re: A tool to send email ?

Postby Armando » Sat May 07, 2011 1:34 am

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
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: A tool to send email ?

Postby Enrico Maria Giordano » Sat May 07, 2011 10:44 am

Here it is:

Code: Select all  Expand view  RUN
#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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A tool to send email ?

Postby Armando » Sat May 07, 2011 12:07 pm

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
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: A tool to send email ?

Postby Baxajaun » Tue May 10, 2011 9:25 am

Enrico,

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

Armando,

change hDLL for hLib.

Best regards,

Felix
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: A tool to send email ?

Postby Enrico Maria Giordano » Tue May 10, 2011 9:47 am

Baxajaun wrote:change hDLL for hLib.


Sorry, my fault.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A tool to send email ?

Postby Willi Quintana » Tue May 10, 2011 4:20 pm

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: 1020
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: A tool to send email ?

Postby Enrico Maria Giordano » Tue May 10, 2011 4:26 pm

You don't have to link sndmail.lib. Use sndmail.dll only.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A tool to send email ?

Postby Willi Quintana » Tue May 10, 2011 4:56 pm

Hi,,, (thanks Giordano)
any example with hotmail???
this is my code:
Code: Select all  Expand view  RUN

 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
Willi Quintana
 
Posts: 1020
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: A tool to send email ?

Postby Enrico Maria Giordano » Tue May 10, 2011 8:15 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A tool to send email ?

Postby zazibr » Thu May 19, 2011 3:45 pm

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
zazibr
 
Posts: 71
Joined: Mon Jan 28, 2008 11:18 am
Location: Campo Grande,MS, BRASIL

Re: A tool to send email ?

Postby ukoenig » Mon Jun 13, 2016 1:50 pm

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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: A tool to send email ?

Postby Enrico Maria Giordano » Mon Jun 13, 2016 2:20 pm

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

Code: Select all  Expand view  RUN
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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A tool to send email ?

Postby ukoenig » Mon Jun 13, 2016 2:25 pm

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 29 guests