mapping network drive inside application -is it possible?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: mapping network drive inside application -is it possible?

Post by franco »

Theo,
After a couple of hours can not get to work. I do not know the required fields.
Required. IP or domain name of the mail server ? I no not know
Required. Email address of the sender
Required. Email addresses to send the email to
Required. User name for the POP3 server
Required. Password for User
Required. POP3 server name or address

if my email address was me@gmail.com password me
I am sending to u@gmail.com
there are 4 more required fields
If I am using google mail
do you know what the POP server name or address would be .
would the user name for pop3 server be.... me@gmail.com
would the Password for user be.... me
If I could get a simple email working then I could add other items to it later.
Thanks Franco
All The Best,
Franco
Canada
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: mapping network drive inside application -is it possible?

Post by franco »

yes, I have tried
smtp server smtp.gmail.com
port 587
pop server pop.gmail.com
smtp user me@gmail.com
smtp password me
mail to me@gmail.com
mail from me@gmail.com

Marek I ran across your sendmail program and tried it with the above settings but also does not send.
does that program work in 3.4.4
Thanks Franco
All The Best,
Franco
Canada
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: mapping network drive inside application -is it possible?

Post by edk »

Franco, It seems to me that Gmail requires SSL.
I think, you should include SSL support: viewtopic.php?f=9&t=586&start=24
Although the description is for hb_tip, but it also applies to hb_SendMail.

Personally I prefer to use CDO.Message (thx Pablo César :!: viewtopic.php?f=6&t=5033&hilit=CDO.Message&start=14 ) instead of hb_sendmail (), you can try this:

Code: Select all

#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
		:HTMLBody 	:= sm_Body
		:HTMLBodyPart:Charset := "utf-8"
		:AddAttachment :="c:\temp\readme.txt"
		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()
	ENDWITH

	CATCH oError
		lsm:=.F.
		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
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: mapping network drive inside application -is it possible?

Post by franco »

I tried this. Seems to make sense to me but will not run. I am sure problem lies with
:Item( "http://schemas.microsoft.com/cdo/config ... smtpusessl" ) :Value := lSSL
Do I have to include ssl here also.
I do not understand how to get it.
Thanks again Franco
All The Best,
Franco
Canada
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: mapping network drive inside application -is it possible?

Post by edk »

For Gmail set:

Code: Select all

lSSL := .T.
sm_portsmtp := 465 
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: mapping network drive inside application -is it possible?

Post by franco »

Here is my Complete program

Code: Select all

#include <hmg.ch>

#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:=1 //is for High; =1 for Normal; =0 for Low
	sm_confirm_read:=.T. //is for return receipt
	sm_servsmtp := 'smtp.gmail.com'
	sm_portsmtp := 465
	lSSL := .T.
	sm_from := 'MY@gmail.com'
	sm_to := 'MY@gmail.com'
	sm_subject := 'tr'
	sm_bcc:= ''
	sm_cc := ''
	sm_body := 'tr'
	sm_priority := 2
	sm_userauth := 'MY@gmail.com'
	sm_passauth := 'MYPASS'

	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
		:HTMLBody 	:= sm_Body
		:HTMLBodyPart:Charset := "utf-8"
		:AddAttachment :=   "c:\temp\readme.txt"
		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()
	ENDWITH

	CATCH oError
		lsm:=.F.
		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 get error
Error: 1
Subcode: 1006
OSCode: -2147352573
SubSystem: WINOLE
Description: Argument error
When I look this error up is says ..... Member Not Found

Franco :(
All The Best,
Franco
Canada
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: mapping network drive inside application -is it possible?

Post by edk »

Do you have existing attachment "c:\temp\readme.txt" ? If not just remove this line :AddAttachment := "c:\temp\readme.txt"
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: mapping network drive inside application -is it possible?

Post by franco »

yes I have it. Did you try it without. I will try and let you know.
Thanx Franco
All The Best,
Franco
Canada
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: mapping network drive inside application -is it possible?

Post by edk »

Now I am without a PC, check also sm_body, it should be in Html. Try

Code: Select all

sm_body := "<html> Test </html>"
I will try to prepare a working demo tomorrow.
Post Reply