Sending emails from the program

218 views
Skip to first unread message

Krzys Stank

unread,
Apr 1, 2020, 6:38:29 AM4/1/20
to Harbour Minigui
Hello MiniGui fans.

I am in need of sending  emails  from the program, I launched three examples added to the MiniGui distribution, none of them work.
I may be making a mistake.

Can any of you send mail from your own program and give a working example?

Any suggestion is appreciated thanks.

Krzysztof Stankiewicz
Poland Gdansk

Grigory Filatov

unread,
Apr 1, 2020, 7:19:33 AM4/1/20
to Harbour Minigui
Hello  Krzysztof,

I've tested the following Harbour code only program with the SSL encryption mail server:

FUNCTION main()
   LOCAL oEmailMsg
   LOCAL cSchema := "http://schemas.microsoft.com/cdo/configuration/"
   
      oEmailMsg  := CREATEOBJECT ( "CDO.Message" )
      WITH OBJECT oEmailMsg
     
         :From     := "gfil...@myserver.com"
         :To       := "gfil...@otherserver.com"
         :CC       := ""
         :BCC      := ""
         :Subject  := "Subject"
         :TextBody := "Some Text"
         :AddAttachment( "c:\test\email.prg" )
              
         WITH OBJECT :configuration:Fields
            :Item( cSchema + "smtpserver" ):Value       := "smtp.myserver.com
            :Item( cSchema + "smtpserverport" ):Value   := 465
            :Item( cSchema + "sendusing" ):Value        := 2
            :Item( cSchema + "smtpauthenticate" ):Value := .T.
            :Item( cSchema + "smtpusessl" ):Value       := .T.
            :Item( cSchema + "sendusername" ):Value     := "gfil...@myserver.com"
            :Item( cSchema + "sendpassword" ):Value     := "somepasword"
            :Item( cSchema + "smtpconnectiontimeout"):Value := 30
            :Update()
         END WITH        
         :Send()
      END WITH
RETURN NIL

It works fine here.

My build script is below:

@if "%MG_BCC%"=="" set MG_BCC=c:\borland\bcc58
@set PATH=%MG_BCC%\bin;%PATH%
@call ..\..\..\harbour\bin\hbmk2 -lhbwin -lxhb email.prg

Note that you will need a mail server with SMTP support.

HTH,
Grigory

среда, 1 апреля 2020 г., 13:38:29 UTC+3 пользователь Krzysztof Stankiewicz написал:

Krzysztof Stankiewicz

unread,
Apr 4, 2020, 4:42:28 AM4/4/20
to Harbour Minigui
Hello

Before sending this request for help, I was unable to send any mail from the examples in MiniGui / examples or in any other way from the program. Works without any problems: Thunderbird

I received an example from Grigory, it worked.
I pasted an example into my program and it worked the first time.
after changing the addresses to the correct ones. He stopped sending mail. I came back to the previous one and neither. I started the Grigory example again and did not send anything, it showed an SSL error.
I checked what it is: Account does not exist or password error.
I returned to my program and it turned out to work.
I sent a few more times and it stopped working again?
I suspect the problem of MS Windows 7, I will look for the reason, but I think that reinstallation is necessary.

Thank you Grigory and everyone willing to help.

Krzysztof Stankiewicz
Poland Gdansk
Reply all
Reply to author
Forward
0 new messages