Send EMail Within FW Appplication (RESOLVED)
Send EMail Within FW Appplication (RESOLVED)
Hi All,
A client has asked to send a payslip via email to all employees from the payroll module. This requires sending the email from Gmail to Gmail users. All employees have an email address in their profile, get tagged for an email.
I have tried some examples from this forum and also tested testsmtp.prg. But with no success.
I have provided sendmail() with from/to/subject/message/password/attachment..all the parameters. No success..
Is there a test prg available to share, for me to get the concept clear?
Thnx in advance...
A client has asked to send a payslip via email to all employees from the payroll module. This requires sending the email from Gmail to Gmail users. All employees have an email address in their profile, get tagged for an email.
I have tried some examples from this forum and also tested testsmtp.prg. But with no success.
I have provided sendmail() with from/to/subject/message/password/attachment..all the parameters. No success..
Is there a test prg available to share, for me to get the concept clear?
Thnx in advance...
Last edited by RiazKhan on Sat Jun 12, 2021 6:59 pm, edited 1 time in total.
- Rick Lipkin
- Posts: 2668
- Joined: Fri Oct 07, 2005 1:50 pm
- Location: Columbia, South Carolina USA
Re: Send EMail Within FW Appplication....
RiazKhan
Don't forget .. you will need to "allow less secure apps" to be turned on for the sending gmail account ..
Rick Lipkin
Don't forget .. you will need to "allow less secure apps" to be turned on for the sending gmail account ..
Rick Lipkin
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
Disable 2-step verification
Open your Google Account.
In the "Security" section, select 2-Step Verification. You may need to login.
Select Disable.
A pop-up window will appear to confirm that you want to disable 2-step verification. Select Disable.
Regards.
Open your Google Account.
In the "Security" section, select 2-Step Verification. You may need to login.
Select Disable.
A pop-up window will appear to confirm that you want to disable 2-step verification. Select Disable.
Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Send EMail Within FW Appplication....
Yes, Thank you for your prompt reply..
I already have set these as in my Gmail account....
Allow Less Secure Apps - is ON
2-step verification - DISABLED
I am passing all parameters to sendmail()
SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort,lNotification , lSSL )
This is the return message : "Unsent message check windows live mail"
LOCAL cFrom := "amriazkhan@gmail.com"
LOCAL cServer := "smtp.gmail.com"
LOCAL cTo := "TO Address"
LOCAL cSubject := "Test message"
LOCAL cMessage := "This is a test message."
LOCAL cSender := "amriazkhan@gmail.com"
LOCAL cUser := "amriazkhan@gmail.com"
LOCAL cPassword := "xxxxxxxx"
LOCAL aAttach := {}
LOCAL aCc := "" //???
LOCAL lHtml := .F.
LOCAL lSSL := .F.
LOCAL cPort := "465"
LOCAL lNotification := .F.
LOCAL lRet := .F.
Any parameter missing..??
I already have set these as in my Gmail account....
Allow Less Secure Apps - is ON
2-step verification - DISABLED
I am passing all parameters to sendmail()
SENDMAIL( cFrom, cServer, cTo, cSubject, cMessage, aAttach, cSender, cUser, cPassword, aCc, lHtml, cPort,lNotification , lSSL )
This is the return message : "Unsent message check windows live mail"
LOCAL cFrom := "amriazkhan@gmail.com"
LOCAL cServer := "smtp.gmail.com"
LOCAL cTo := "TO Address"
LOCAL cSubject := "Test message"
LOCAL cMessage := "This is a test message."
LOCAL cSender := "amriazkhan@gmail.com"
LOCAL cUser := "amriazkhan@gmail.com"
LOCAL cPassword := "xxxxxxxx"
LOCAL aAttach := {}
LOCAL aCc := "" //???
LOCAL lHtml := .F.
LOCAL lSSL := .F.
LOCAL cPort := "465"
LOCAL lNotification := .F.
LOCAL lRet := .F.
Any parameter missing..??
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
Code: Select all | Expand
{"@pop.gmail.com", "smtp.gmail.com", 465, .T. },;
LOCAL cFrom := "amriazkhan@gmail.com"
LOCAL cServer := "smtp.gmail.com"
LOCAL cTo := "TO Address"
LOCAL cSubject := "Test message"
LOCAL cMessage := "This is a test message."
LOCAL cSender := "amriazkhan@gmail.com"
LOCAL cUser := "amriazkhan@gmail.com"
LOCAL cPassword := "xxxxxxxx"
LOCAL aAttach := {}
LOCAL aCc := "" //???
LOCAL lHtml := .F.
LOCAL lSSL := .T. // .F.
LOCAL cPort := "465"
LOCAL lNotification := .F.
LOCAL lRet := .F.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
Check if gmail has "temporarily blocked" account access.
From time to time, or when you create a new account and try to use an external program to transmit email, gmail blocks access for "suspected misuse" and asks for account confirmation.
Generally, to resolve this, go through your browser, log out of your account and try logging in again.
Gmail will ask for confirmation and send a code to your cell phone.
Do the procedure and gmail will grant access again.
It happened a few times with some of our clients, and after I confirmed the account, the program started sending again normally.
Regards.
From time to time, or when you create a new account and try to use an external program to transmit email, gmail blocks access for "suspected misuse" and asks for account confirmation.
Generally, to resolve this, go through your browser, log out of your account and try logging in again.
Gmail will ask for confirmation and send a code to your cell phone.
Do the procedure and gmail will grant access again.
It happened a few times with some of our clients, and after I confirmed the account, the program started sending again normally.
Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Send EMail Within FW Appplication....
Thanks ....for your support.
I have tried many ways...to send an email from my application....but it does not respond...
Part of the function is listed below...from this forum..
******************************************************************************************************
STATIC 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
***************************************************************************************
No luck....
I have tried many ways...to send an email from my application....but it does not respond...
Part of the function is listed below...from this forum..
******************************************************************************************************
STATIC 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
***************************************************************************************
No luck....
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
Mensagem enviada com sucesso. -> Message sent successfully.
https://i.imgur.com/6V830B9.png
My sender is working fine. Had to turn off google security.
Allow less secure apps: ON
https://i.imgur.com/0I024bs.png
Regards, saludos.
https://i.imgur.com/6V830B9.png
My sender is working fine. Had to turn off google security.
Allow less secure apps: ON
https://i.imgur.com/0I024bs.png
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7928
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: Send EMail Within FW Appplication....
https://myaccount.google.com/security?pmr=1
https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4NBKR97Jli4gceS35qOxkYX6FnEL3I6uGkA5Qg_5ftggb_siiMQ6LLQKX20I4sA4x8BkkrYirPuZrD4ssJgnjgjqz2zbw
I use the RMAIL.PRG modified by me for use in the company I work for and it works very well. If you wish, I send the link for you to download and test. Greetings.
Regards, saludos.
https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4NBKR97Jli4gceS35qOxkYX6FnEL3I6uGkA5Qg_5ftggb_siiMQ6LLQKX20I4sA4x8BkkrYirPuZrD4ssJgnjgjqz2zbw
I use the RMAIL.PRG modified by me for use in the company I work for and it works very well. If you wish, I send the link for you to download and test. Greetings.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Send EMail Within FW Appplication....
Thanks Karinha,
Yes, I will appreciate it very much if you can send, me the link of rmail.prg for testing purposes...
As I feel I am doing all my settings right with google security.
amriazkhan@gmail.com
Regards
Yes, I will appreciate it very much if you can send, me the link of rmail.prg for testing purposes...
As I feel I am doing all my settings right with google security.
amriazkhan@gmail.com
Regards
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Send EMail Within FW Appplication....
Here is a very old message thread discussing this topic.
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15843&p=82081&hilit=gmail#p82081
Also note the info about the firewall blocking port 465.
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=15843&p=82081&hilit=gmail#p82081
Also note the info about the firewall blocking port 465.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Re: Send EMail Within FW Appplication....
Thank You,
James & Santos..
Will check..both solutions...and will get back to you..
Kind Regards..
James & Santos..
Will check..both solutions...and will get back to you..
Kind Regards..