framework para HMG

HMG en Español

Moderator: Rathinagiri

User avatar
mustafa
Posts: 1172
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: framework para HMG

Post by mustafa »

Hola Franco
Pero el problema está cuando intentamos mandar un e-mail desde nuestra
aplicación se produce un Error porque no están otorgados los permiso
a la cta. del remitente, pero como conseguir que obtenga permiso
el usuario de nuestra aplicación ?
Saludos
*---------------------------------------------------------------------------------*
Hello Franco
But the problem is when we try to send an e-mail from our
Application fails because the permissions are not granted
to the cta. sender, but how to get permission
the user of our application?
Regards

Mustafa
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: framework para HMG

Post by danielmaximiliano »

Hola Mustafá: mi inconveniente no es conectarme con Gmail o otros servidores de correo mediante POP3 no de enviar mediante smtp.
La seguridad de IMAPs es con respecto a la autentificación de usuarios mediante la API de Gmail. Esto se Lee aquí.
https://developers.google.com/gmail/ima ... 2-protocol
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: framework para HMG

Post by jairpinho »

Ola Daniel segue algo que tentei usar

https://medium.com/@pablo127/google-api ... 03c897fd98
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
franco
Posts: 877
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: framework para HMG

Post by franco »

Hello all.
this is what I use out of all my programs. Started from an example by Rathi I believe
You must have a gmail account with security allow less secure apps set to to Y
I only use this email address for sending emails. I have forward incoming mail set to another email account.
I compile with batch file c:\3.44\build c:\email\cdo in the c:\email\cdo folder. CDO.PRG

Code: Select all

#include "hmg.ch"

Function Main
*** You could put for sm_to and sm_body below      ----  sm_to := inputbox("Enter To EmailAddress")  and sm_body := inputbox{"Enter Message")

Local cPath:= GetCurrentFolder()+"\", loCfg, loMsg
Local sm_to:=  "email address where you want to send to "
Local sm_from:= "your email address"    (with security turned to less secure programs)
Local sm_cc:=""
Local sm_bcc:=""
Local sm_userauth:= "your email address"
Local sm_passauth:= "your password for above email address"
Local sm_subject:="Direct Email. "
Local sm_servsmtp:="smtp.gmail.com"
Local sm_portsmtp:=465
Local sm_confirm_read:=.T.
Local sm_Body:='<html><head><meta content="text/html; charset=utf-8" http-equiv="content-type"><title></title></head><body>'+;
			'htThis is sent through (CREATEOBJECT), (GOES THOUGH MICROSOFT SCHEMAS)</body></html>'
Local sm_TextBody:="This is sent through new direct mail out of program. When in invoice click email if customer has email in his file it sends."
Local lSSL:=.T.   
Local sm_priority:=1
Local sm_att:= cPath+"AttSample.zip"


#xcommand TRY              => BEGIN SEQUENCE WITH {|o| break(o)}
#xcommand CATCH [<!oErr!>] => RECOVER [USING <oErr>] <-oErr->
#xcommand FINALLY          => ALWAYS
	
//Please note, when using the :AddAttachment method in your scripts you must use a fully qualified pathname as the argument to the method.  Using //just a file name or a relative path will produce the error The specified protocol is unknown
//By repeating the :AddAttachment method you can attach more than one file.
//sm_priority:=2 is for High; =1 for Normal; =0 for Low
//sm_confirm_read:=.T. is for return receipt

TRY
	
	loCfg := CREATEOBJECT( "CDO.Configuration" )
	WITH OBJECT loCfg:Fields
		:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" )      :Value := sm_servsmtp
		:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" )  :Value := sm_portsmtp
		: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 := lSSL
		:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" )    :Value := sm_userauth
		:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" )    :Value := sm_passauth
		:Update()
	END WITH

	loMsg := CREATEOBJECT ( "CDO.Message" )

	WITH OBJECT loMsg
		:BodyPart:Charset := "utf-8"
		:Configuration := loCfg
 		:From          := sm_from
		:To            := sm_to
		:Subject       := sm_subject
		:Bcc 		:= sm_bcc
		:Cc 			:= sm_cc
		:TextBody 	:= sm_TextBody			//plain text
		:HTMLBody 	:= sm_Body			//html text
		:HTMLBodyPart:Charset := "utf-8"  
		:AddAttachment (sm_att)		
		WITH OBJECT loMsg:Fields
			:Item("urn:schemas:httpmail:importance"):Value := sm_priority
			:Item("urn:schemas:mailheader:X-Priority"):Value := sm_priority-1
			IF sm_confirm_read
				:Item("urn:schemas:mailheader:return-receipt-to"):Value := sm_from
				:Item("urn:schemas:mailheader:disposition-notification-to"):Value := sm_from
			ENDIF
			:Update()
		ENDWITH
		:DSNOptions := 0
		:Send()
		MsgInfo('Success')
	ENDWITH
	
CATCH oError
		MsgStop ( "The email was not sent."+CRLF+;
				"Error:      "+TRANSFORM(oError:GenCode, NIL)+CRLF+;
				"SubCode:   "+TRANSFORM(oError:SubCode, NIL)+CRLF+;
				"OSCode:    "+TRANSFORM(oError:OsCode, NIL)+CRLF+;
				"SubSystem: "+TRANSFORM(oError:SubSystem, NIL)+CRLF+;
				"Description:      "+oError:Description)
END


RETURN
*********************************************************************************
I hope this will work for you.
All The Best,
Franco
Canada
Pcmodula
Posts: 36
Joined: Thu Nov 22, 2012 6:00 pm

Re: framework para HMG

Post by Pcmodula »

martingz wrote: Thu Aug 20, 2020 7:00 pm Pcmodula, use it, but when I compile my program the rpt file is included in the exe, when I make a modification and launch the report from my application it always executes the old one, I have to compile again and my now if it shows with the changes, I can't find The last one I did, there I already had a preview of the report and it was more finished.
Martin, maybe you are using the wrong demo.
Now that I finally have my pc available, I suggest you try C:\MiniGui\SAMPLES\Advanced\REPORT_GENERATOR_2, it allows you to change the report without recompiling, just edit the rpt file and it works with Miniprint, hbprinter, pdfprint, html!
Last thing, with the latest version you need to replace gete("os") with hb_GetEnv ("OS") into STATIC ChangeFunc () ,otherwise it goes wrong (I have already reported this to Grigory)

Best Regards
Pcmodula
Post Reply