Sending Mail
Moderator: Rathinagiri
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Sending Mail
Hi All,
I'm developing an utility that sits on system tray and once a day (at specific time) checks the content of a MySql table.
Depending of the content of the table, I must to send an email warning to certain customers.
The mail account to be used is a Gmail one.
So, the question is, which is currently the best method to send a mail using a Gmail account from an HMG app (is preferable that not mail client be required).
TIA.
I'm developing an utility that sits on system tray and once a day (at specific time) checks the content of a MySql table.
Depending of the content of the table, I must to send an email warning to certain customers.
The mail account to be used is a Gmail one.
So, the question is, which is currently the best method to send a mail using a Gmail account from an HMG app (is preferable that not mail client be required).
TIA.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Sending Mail
Field expert is Daniel Maximilian,Roberto Lopez wrote:Hi All,
I'm developing an utility that sits on system tray and once a day (at specific time) checks the content of a MySql table.
Depending of the content of the table, I must to send an email warning to certain customers.
The mail account to be used is a Gmail one.
So, the question is, which is currently the best method to send a mail using a Gmail account from an HMG app (is preferable that not mail client be required).
TIA.
I hope he will come soon ...
Best regards
Viva INTERNATIONAL HMG
Re: Sending Mail
Thanks.I've implemented CDO (pattern from our forum). It works OK, one of my clients sends hundreds of mails with attachments everyday.
Does it requires that an email client be installed to make it work?
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Sending Mail
Marek,
By mistake, I've edited your post instead of reply it (I've confused the buttons).
I'm very sorry for that (is early in the morning here and I've not drink my cofee yet .
Could be you so kind to post the code again?
Thanks.
By mistake, I've edited your post instead of reply it (I've confused the buttons).
I'm very sorry for that (is early in the morning here and I've not drink my cofee yet .
Could be you so kind to post the code again?
Thanks.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
Re: Sending Mail
Hi Roberto,
Harbour have now an own e-mail support with SSL via the function hb_SendMail().
There is a sample of usage in the file harbour\contrib\hbtip\tests\gmail.prg.
Also is important that you should installed the OpenSSL on your computer.
Code sample:
Hope that useful.
Harbour have now an own e-mail support with SSL via the function hb_SendMail().
There is a sample of usage in the file harbour\contrib\hbtip\tests\gmail.prg.
Also is important that you should installed the OpenSSL on your computer.
Code sample:
Code: Select all
hb_SendMail( ;
"smtp.gmail.com", ;
465, ;
cFrom, ;
cTo, ;
NIL /* CC */, ;
{} /* BCC */, ;
"Test message", ;
"Test subject", ;
{"gmail.prg"} /* attachment */, ;
cFrom, ;
cPassword, ;
"", ;
NIL /* nPriority */, ;
NIL /* lRead */, ;
.T. /* lTrace */, ;
.F., ;
NIL /* lNoAuth */, ;
NIL /* nTimeOut */, ;
NIL /* cReplyTo */, ;
.T., ;
NIL /* cSMTPPass */, ;
"es-ar" )
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
-
- Posts: 683
- Joined: Tue Jun 04, 2013 6:33 pm
- Location: Argentina
Re: Sending Mail
Hi Roberto:
Here i attach CDOSYS mail (i think is last version Daniel Maximiliano creates).-
I don't test it, so i don't know how it works.-
Hope this helps you.-
Mol also develope a good send mail system.- I'll look where i've put it, and upload then.-
Please tell us if it woks.-
With regards.
Eduardo
Here i attach CDOSYS mail (i think is last version Daniel Maximiliano creates).-
I don't test it, so i don't know how it works.-
Hope this helps you.-
Mol also develope a good send mail system.- I'll look where i've put it, and upload then.-
Please tell us if it woks.-
With regards.
Eduardo
- Attachments
-
- MAIL_SEND_D_MAXIMILIANO.zip
- (1.55 MiB) Downloaded 377 times
Re: Sending Mail
my working code based on Daniel example:
Code: Select all
BEGIN SEQUENCE WITH {|e| break(e)}
oCfg := CREATEOBJECT( "CDO.Configuration" )
WITH OBJECT oCfg:Fields
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) :Value := cSystemowySMTPServer
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) :Value := nSystemowySMTPPort
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ) :Value := 2
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T.
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ) :Value := lSystemowySMTPSSL
:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") :Value := 1
:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ) :Value := cSystemowySMTPUser
:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ) :Value := cSystemowySMTPPassword
:Update()
END WITH
oMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oMsg
:Configuration := oCfg
:BodyPart:Charset := "windows-1250"
//:BodyPart:Charset := "utf-8"
//:From := hb_strtoutf8(OknoWyslijWiadomosc.T_ODKogo.Value,"PLWIN")
:From := alltrim(OknoWyslijWiadomosc.T_ODKogo.Value)
:To := alltrim(OknoWyslijWiadomosc.T_DO.Value)
:CC := alltrim(OknoWyslijWiadomosc.T_DW.Value)
:Subject := alltrim(OknoWyslijWiadomosc.T_Temat.Value)
:TextBody := rtrim(OknoWyslijWiadomosc.T_Tresc.Value) + e"\r\n"
//TODO: To send HTML body, uncomment the following lines:
//String cHtml;
//cHtml := "<HTML>\n" + ;
// "<HEAD>\n" + ;
// "<TITLE>Sample GIF</TITLE>\n" + ;
// "</HEAD>\n" + ;
// "<BODY><P>\n" + ;
// "<h1><Font Color=Green>Inline graphics</Font></h1>\n" + ;
// "</BODY>\n" + ;
// "</HTML>"
//:TextBody := cHtml
//TODO: To send WEb page in an e-mail, uncomment the following lines and make changes in TODO section.
//TODO: Replace with your preferred Web page
//:CreateMHTMLBody("http://www.microsoft.com",
// CDO.CdoMHTMLFlags.cdoSuppressNone,
// "", "")
// :Subject = "Test SMTP";
for i:=1 to len(aZalaczniki)
:AddAttachment(aZalaczniki[i])
next i
:Send()
ENDWITH
RECOVER USING e
MsgStop ( "Nie udało się wysłać wiadomości z powodu:" + Chr(13) + Chr(10) + ;
"opis błędu: " + e:Description +chr(10)+;
"sprawdź ustawienia konta pocztowego lub zabezpieczenia, np. firewall")
//"Error: " + TRANSFORM(e:GenCode , NIL) + Chr(13) + Chr(10) + ;
//"SubC: " + TRANSFORM(e:SubCode , NIL) + Chr(13) + Chr(10) + ;
//"OSCode: " + TRANSFORM(e:OsCode , NIL) + Chr(13) + Chr(10) + ;
//"SubSystem: " + TRANSFORM(e:SubSystem , NIL) + Chr(13) + Chr(10) + ;
Wait Clear
Return
END
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Sending Mail
Marek,
Thanks for all the info about this.
I've successfully made work hb_sendmail() with a gmail account.
My goal is always to make my apps portable, not requiring another things installed. This is the reason to avoid solutions involving mail clients.
In this case, is not necessary to install SSL on the destination machine. Copying, the required dlls (only two) to the app folder, is enough to make it work.
Thanks Again!
Thanks for all the info about this.
I've successfully made work hb_sendmail() with a gmail account.
My goal is always to make my apps portable, not requiring another things installed. This is the reason to avoid solutions involving mail clients.
In this case, is not necessary to install SSL on the destination machine. Copying, the required dlls (only two) to the app folder, is enough to make it work.
Thanks Again!
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Sending Mail
I've finally decided to use hb_sendmail() because it worked fine in the first attempt and I must to complete the app for tomorrow (no time for experimentation )EduardoLuis wrote:Here i attach CDOSYS mail (i think is last version Daniel Maximiliano creates).-
I don't test it, so i don't know how it works.-
Hope this helps you.-
I'll make more experimentation when have some available time. I'll look for CDO for next developments.
Thanks!
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Sending Mail
Grigory:gfilatov wrote:Harbour have now an own e-mail support with SSL via the function hb_SendMail().
There is a sample of usage in the file harbour\contrib\hbtip\tests\gmail.prg.
Also is important that you should installed the OpenSSL on your computer.
It worked like a charm in the first attempt.
As I've explained to Marek, is not required to install SSL in the destination machine.
Copying some of the dlls to the app folder is enough to make it work.
Thanks Again!
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)