email - blat.exe

email - blat.exe

Postby Otto » Thu Aug 04, 2016 7:15 am

Hello,

blat.exe
I am working on a setup for my windows server backup.

I found some solutions where you get a notification through an email sent by blat.exe.

I blat.exe a secure software.
Can we send emails only with Fivewin, too.

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: email - blat.exe

Postby Enrico Maria Giordano » Thu Aug 04, 2016 8:17 am

This is what I'm using without problems:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL cFrom         := "e.m.giordano@emagsoftware.it"
    LOCAL cServer       := "out.alice.it"
    LOCAL cTo           := "e.m.giordano@emagsoftware.it"
    LOCAL cSubject      := "Test message"
    LOCAL cMessage      := "This is a test message."
    LOCAL aAttach       := NIL
    LOCAL cSender       := NIL
    LOCAL cUser         := NIL
    LOCAL cPassword     := NIL
    LOCAL aCC           := NIL
    LOCAL lHtml         := NIL
    LOCAL cPort         := NIL
    LOCAL lNotification := NIL
    LOCAL lSSL          := NIL

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

    RETURN NIL


#command IF <condition> THEN <*statements*> => if <condition> ; <statements> ; end


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 ) THEN cFrom = ["] + cSender + ["] + " <" + cFrom + ">"

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

        IF !EMPTY( aCc )
            FOR i = 1 TO LEN( aCc )
                IF i > 1 THEN cCc += ";"
                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: 8524
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: email - blat.exe

Postby Otto » Thu Aug 04, 2016 8:43 am

Hello Enrico,
thank you. I will try your solution.
Best regards,
Otto

PS:
Are you travelling to the Dolomites in ferragosto?


Our problems at the moment:

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: email - blat.exe

Postby Enrico Maria Giordano » Thu Aug 04, 2016 8:48 am

Otto wrote:Are you travelling to the Dolomites in ferragosto?


Unfortunately not. :-(

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

Re: email - blat.exe

Postby dtussman » Thu Aug 04, 2016 3:21 pm

In Enrico's example I don't see where he is defining the port. Doesn't CDO require the port? Also, I assume this example would not work with Outlook or Office 365.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: email - blat.exe

Postby Enrico Maria Giordano » Thu Aug 04, 2016 3:24 pm

dtussman wrote:In Enrico's example I don't see where he is defining the port. Doesn't CDO require the port?


Code: Select all  Expand view
LOCAL cPort         := NIL


The default value is used (25, if I remember correctly). You can assign any other (string) value you need:

Code: Select all  Expand view
LOCAL cPort         := "587"


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

Re: email - blat.exe

Postby Enrico Maria Giordano » Thu Aug 04, 2016 3:25 pm

dtussman wrote:Also, I assume this example would not work with Outlook or Office 365.


I don't understand, sorry.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 25 guests