New Fivewin with new PDF
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
New Fivewin with new PDF
I am testing the new Fivewin 21.11 and have been creating PDF's with the FwPdf class and it works great. Does anybody know how to be sure when the FwPdf class releases the file, or can you make sure it has released the file before moving on in the program. I am immediately needing to email the file as an attachment and need to make sure it is available before I attempt to send the email?
Thanks,
Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
Re: New Fivewin with new PDF
Code: Select all | Expand
if File( "myfile.pdf" )
...
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Re: New Fivewin with new PDF
hi,
as long PDF is "not finish" Size is 0
i do have same Problem when create "ZIP" Files which work "asynchron"
Code: Select all | Expand
if File( "myfile.pdf" ) .AND. FilesSire > 0
as long PDF is "not finish" Size is 0
i do have same Problem when create "ZIP" Files which work "asynchron"
greeting,
Jimmy
Jimmy
Re: New Fivewin with new PDF
Jimmy, yes, very good your post
Code: Select all | Expand
if File( "myfile.pdf" ) .and hb_fsize( "myfile.pdf" ) > 0 // 10
...
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: New Fivewin with new PDF
All, thanks for the responses but I was hoping I could find a way to determine that the file is created and the file handle has been released with out testing for it. I have been working with PDF995 and the reason I moved to using the new fivewin was with the hope that I would not have to test for the existence of the file, test for size (and what I found out is that just not equal to zero will not work, the file may read several sizes before it is complete). Is there a way for the program to stop on the line where it is writing the file to the disc, and not move on until it is complete. Where I can be sure the file is there, complete, and released. Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: New Fivewin with new PDF
Good afternoon. Have you tried with HTMLVIEW()?
Look:
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=40928&start=0&hilit=HTMLVIEW&sid=a6be1cc0776c127e24f72f61a8bd056f
Regards, saludos.
Look:
http://forums.fivetechsupport.com/viewtopic.php?f=6&t=40928&start=0&hilit=HTMLVIEW&sid=a6be1cc0776c127e24f72f61a8bd056f
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Antonio Linares
- Site Admin
- Posts: 42513
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 73 times
- Contact:
Re: New Fivewin with new PDF
Dear Byron,
You could try to rename the PDF file, as meanwhile the file is in use, you will not able to do it:
while FRename( cCurrentName, cNewName ) != 0
SysWait()
end
You could try to rename the PDF file, as meanwhile the file is in use, you will not able to do it:
while FRename( cCurrentName, cNewName ) != 0
SysWait()
end
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: New Fivewin with new PDF
This problem may be related to the new programming environment for my new FWHarbour libs. Is it possible that if I don't have the libs in the correct order I could have problems. I am getting the following message:
Could not send message;Error: 1;SubC: 1006;OSCode: -2147352573;SubSystem: WINOLE;Message: Argument error
This seems to happen right when I attempt to attach the file using the oEmailMsg:AddAttachment method.
If I don't include an attachment the email sends fine. Is there a way to get better information on the Argument error to help debug?
Thanks,
Could not send message;Error: 1;SubC: 1006;OSCode: -2147352573;SubSystem: WINOLE;Message: Argument error
This seems to happen right when I attempt to attach the file using the oEmailMsg:AddAttachment method.
If I don't include an attachment the email sends fine. Is there a way to get better information on the Argument error to help debug?
Thanks,
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: New Fivewin with new PDF
Good Morning,
Show your email sending routine please.
test it too, with my email sending routine: RMAIL.PRG
Download Complete,
https://mega.nz/file/FQFWgIDT#kvRtIHIesRpTw9I8CxJenTRikG4VXM0t_7J8qVQsOX8
Use google translator to change from Portuguese to English, please.
Questions, feel free to ask.
Regards, saludos.
oEmailMsg:AddAttachment method
Show your email sending routine please.
test it too, with my email sending routine: RMAIL.PRG
Download Complete,
https://mega.nz/file/FQFWgIDT#kvRtIHIesRpTw9I8CxJenTRikG4VXM0t_7J8qVQsOX8
Use google translator to change from Portuguese to English, please.
Questions, feel free to ask.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
-
- Posts: 388
- Joined: Sun Nov 06, 2005 3:55 pm
- Location: Southern California, USA
- Contact:
Re: New Fivewin with new PDF
Here is the code for email. Seems to work in xHB using FiveWin 7.01, but it doesn't work with the new FiveWin which makes me think I have something wrong with my make file.
#include "FiveWin.ch"
#DEFINE TRUE .T.
#DEFINE FALSE .F.
function Main()
TestSend()
return nil
Function TestSend()
Local cServer := "smtp.gmail.com"
Local cUserName := "Shipping@mycompany.com"
Local cPassWord := "mypassword"
Local cFrom := "Shipping@mycompany.com"
Local cSubject := DtoC( Date() ) + "-" + Time() + ", SPF Test for EMail"
Local cToAddr := "byron.hopp@gmail.com"
Local cCC := "bhopp@matrixcomputer.com"
Local cBody := "Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
Local cAttach := "c:\PdfFolder\Hopp.pdf"
Local cCsvFile := ""
Local lAttachCsv := FALSE
Local cLogFile := ""
McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Return nil
Function McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Local oError := nil
Local nI := 0
Local oEmailCfg := nil
Local oEmailMsg := nil
Local cHtml := '<!DOCTYPE HTML PUBLIC "-/' + '/W3C/' + '/DTD HTML 4.0 Transitional/' + '/EN">'
cHtml += '<HTML><HEAD>'
cHtml += '<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>'
cHtml += '<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml += '<STYLE></STYLE>'
cHtml += '</HEAD>'
cHtml += '<BODY bgColor=#ffffff>'
cHtml += '<DIV><FONT size=2 face=Courier New>' + cBody + '</FONT></DIV></BODY></HTML>'
Try
oEmailCfg := CreateObject("CDO.Configuration")
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer // "smtp.gmail.com"
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465 // was 587
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // 1 Pickup, 2 Port, 3 Exchange
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := TRUE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := TRUE // FALSE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cUserName
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPassWord
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ):Value := 10
oEmailCfg:Fields:Update()
Catch oError
MsgStop( oError:Description,"CDO.Configuration - cEMailCfg:Fields:Update()")
End Try
Try
oEmailMsg := CreateObject("CDO.Message")
oEmailMsg:Configuration := oEmailCfg
oEmailMsg:From := cFrom // chr(34) + "shipping@mycompany.com" + chr(34) + "<shipping@mycompany.com>"
oEmailMsg:To := cToAddr // "bhopp@matrixcomputer.com"
oEmailMsg:Cc := ""
oEmailMsg:BCc := ""
oEmailMsg:Subject := cSubject
oEmailMsg:MDNRequested := FALSE
oEmailMsg:HTMLBody := cBody
If File( cAttach )
oEmailMsg:AddAttachment := cAttach
Endif
If lAttachCsv .AND. File( cCsvFile )
oEmailMsg:AddAttachment := cCsvFile
Endif
oEmailMsg:Send()
Catch oError
MsgInfo( "Could not send message" + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
End Try
Return nil
#include "FiveWin.ch"
#DEFINE TRUE .T.
#DEFINE FALSE .F.
function Main()
TestSend()
return nil
Function TestSend()
Local cServer := "smtp.gmail.com"
Local cUserName := "Shipping@mycompany.com"
Local cPassWord := "mypassword"
Local cFrom := "Shipping@mycompany.com"
Local cSubject := DtoC( Date() ) + "-" + Time() + ", SPF Test for EMail"
Local cToAddr := "byron.hopp@gmail.com"
Local cCC := "bhopp@matrixcomputer.com"
Local cBody := "Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
Local cAttach := "c:\PdfFolder\Hopp.pdf"
Local cCsvFile := ""
Local lAttachCsv := FALSE
Local cLogFile := ""
McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Return nil
Function McsSendEMail( cServer,cUserName,cPassWord,cFrom,cSubject,cToAddr,cCC,cBody,cAttach,cCsvFile,lAttachCsv,cLogFile )
Local oError := nil
Local nI := 0
Local oEmailCfg := nil
Local oEmailMsg := nil
Local cHtml := '<!DOCTYPE HTML PUBLIC "-/' + '/W3C/' + '/DTD HTML 4.0 Transitional/' + '/EN">'
cHtml += '<HTML><HEAD>'
cHtml += '<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>'
cHtml += '<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml += '<STYLE></STYLE>'
cHtml += '</HEAD>'
cHtml += '<BODY bgColor=#ffffff>'
cHtml += '<DIV><FONT size=2 face=Courier New>' + cBody + '</FONT></DIV></BODY></HTML>'
Try
oEmailCfg := CreateObject("CDO.Configuration")
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer // "smtp.gmail.com"
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465 // was 587
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // 1 Pickup, 2 Port, 3 Exchange
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := TRUE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := TRUE // FALSE
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendusername" ):Value := cUserName
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := cPassWord
oEmailCfg:Fields:Item( "http:" + "/" + "/" + "schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" ):Value := 10
oEmailCfg:Fields:Update()
Catch oError
MsgStop( oError:Description,"CDO.Configuration - cEMailCfg:Fields:Update()")
End Try
Try
oEmailMsg := CreateObject("CDO.Message")
oEmailMsg:Configuration := oEmailCfg
oEmailMsg:From := cFrom // chr(34) + "shipping@mycompany.com" + chr(34) + "<shipping@mycompany.com>"
oEmailMsg:To := cToAddr // "bhopp@matrixcomputer.com"
oEmailMsg:Cc := ""
oEmailMsg:BCc := ""
oEmailMsg:Subject := cSubject
oEmailMsg:MDNRequested := FALSE
oEmailMsg:HTMLBody := cBody
If File( cAttach )
oEmailMsg:AddAttachment := cAttach
Endif
If lAttachCsv .AND. File( cCsvFile )
oEmailMsg:AddAttachment := cCsvFile
Endif
oEmailMsg:Send()
Catch oError
MsgInfo( "Could not send message" + ";" + ;
"Error: " + TRANSFORM(oError:GenCode, NIL) + ";" + ;
"SubC: " + TRANSFORM(oError:SubCode, NIL) + ";" + ;
"OSCode: " + TRANSFORM(oError:OsCode, NIL) + ";" + ;
"SubSystem: " + TRANSFORM(oError:SubSystem, NIL) + ";" + ;
"Message: " + oError:Description )
End Try
Return nil
Thanks,
Byron Hopp
Matrix Computer Services
Byron Hopp
Matrix Computer Services
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: New Fivewin with new PDF
Byron, test your modified example now.
Regards, saludos.
Code: Select all | Expand
// ** Test program for email *** version by kapiabafwh@gmail.com
#include "FiveWin.ch"
FUNCTION Main()
TestSend()
RETURN NIL
FUNCTION TestSend()
/*
LOCAL cServer := "smtp.gmail.com"
LOCAL cUserName := "Shipping@mycompany.com"
LOCAL cPassWord := "MyPassword"
LOCAL cFrom := "Shipping@mycompany.com"
LOCAL cSubject := DToC( Date() ) + "-" + Time() + ", Test for EMail"
LOCAL cToAddr := "byron.hopp@gmail.com"
LOCAL cCC := "bhopp@matrixcomputer.com"
LOCAL cBody := "Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
LOCAL cAttach := "c:\PdfFolder\Hopp.pdf" // any pdf can go here
LOCAL cCsvFile := ""
LOCAL lAttachCsv := .F.
LOCAL cLogFile := ""
*/
// It worked perfect Byron.
LOCAL cServer := "smtp.pleno.com.br"
LOCAL cUserName := "joao@pleno.com.br"
LOCAL cPassWord := "MyPassword"
LOCAL cFrom := "joao@pleno.com.br"
LOCAL cSubject := DToC( Date() ) + "-" + Time() + ", Test for EMail"
LOCAL cToAddr := "kapiabafwh@gmail.com"
LOCAL cCC := "bhopp@matrixcomputer.com"
LOCAL cBcc := "joao@pleno.com.br"
LOCAL cBody := "Body Byron: Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
// LOCAL cAttach := "c:\PdfFolder\Hopp.pdf" // any pdf can go here
LOCAL cAttach := "C:\ORCAMPDF\INSUMOS.PDF"
LOCAL cCsvFile := ""
LOCAL lAttachCsv := .F.
LOCAL cLogFile := ""
IF .NOT. FILE( cAttach )
MsgInfo( "Warning: PDF file, not located in source folder.", ;
"Warning: PDF file, not located in source folder." )
ENDIF
McsSendEMail( cServer, cUserName, cPassWord, cFrom, cSubject, cToAddr, cCC, cBcc, cBody, cAttach, cCsvFile, lAttachCsv, cLogFile )
RETURN NIL
FUNCTION McsSendEMail( cServer, cUserName, cPassWord, cFrom, cSubject, cToAddr, cCC, cBcc, cBody, cAttach, cCsvFile, lAttachCsv, cLogFile )
LOCAL oError, oCfg, oMsg, lRet := .T.
LOCAL cHtml := '<!DOCTYPE HTML PUBLIC "-/' + '/W3C/' + '/DTD HTML 4.0 Transitional/' + '/EN">'
cHtml += '<HTML><HEAD>'
cHtml += '<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>'
cHtml += '<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml += '<STYLE></STYLE>'
cHtml += '</HEAD>'
cHtml += '<BODY bgColor=#ffffff>'
cHtml += '<DIV><FONT size=2 face=Courier New>' + cBody + '</FONT></DIV></BODY></HTML>'
/* // ??? Internal ???
IF Upper( AllTrim( cServer ) ) <> "smtp.gmail.com" .OR. ;
Upper( AllTrim( cUserName ) ) <> "shipping@frupco.com" .OR. ;
AllTrim( cPassWord ) <> "sC-93611"
MsgStop( "Please check the Email Credentials in the INI file, or call MCS.", "McsSendEmail" )
RETURN NIL
ENDIF
*/
Try
oCfg := CreateObject( "CDO.Configuration" )
WITH OBJECT oCfg:Fields
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer // Servidor SMTP
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 587 // nPort
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T. // lAut
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .F. // lSSL // .F. Ou .T.
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := TRIM(cUserName)
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := TRIM(cPassWord)
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 60
oCfg:Update()
END WITH
Catch oError
MsgStop( oError:Description, "CDO.Configuration - cEMailCfg:Fields:Update()" )
End Try
Try
oMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oMsg
oMsg:Configuration := oCfg
oMsg:FROM := cFrom // chr(34) + "shipping@mycompany.com" + chr(34) + "<shipping@mycompany.com>"
oMsg:TO := cToAddr // "bhopp@matrixcomputer.com"
oMsg:Cc := cCC //""
oMsg:BCc := cBcc //""
oMsg:Subject := cSubject
oMsg:MDNRequested := .F.
oMsg:HTMLBody := cBody
IF File( cAttach )
oMsg:AddAttachment := cAttach
ENDIF
IF lAttachCsv .AND. File( cCsvFile )
oMsg:AddAttachment := cCsvFile
ENDIF
:Send()
END WITH
Catch oError
MsgInfo( "Could not send message" + ";" + ;
"Error: " + Transform( oError:GenCode, NIL ) + ";" + ;
"SubC: " + Transform( oError:SubCode, NIL ) + ";" + ;
"OSCode: " + Transform( oError:OsCode, NIL ) + ";" + ;
"SubSystem: " + Transform( oError:SubSystem, NIL ) + ";" + ;
"Message: " + oError:Description )
lRet := .F.
End Try
IF lRet
MsgInfo( "Message sent successfully. Congratulations.", ;
"Message sent successfully. Congratulations." )
ENDIF
oCfg := Nil
oMsg := Nil
RETURN NIL
// fin / end - 05/04/2022 - kapiabafwh@gmail.com - Covid-19
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: New Fivewin with new PDF
Byron, don't forget that starting in May, gmail.com will be disabled for less secure APPs.
Regards, saludos.
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- karinha
- Posts: 7932
- Joined: Tue Dec 20, 2005 7:36 pm
- Location: São Paulo - Brasil
- Been thanked: 3 times
- Contact:
Re: New Fivewin with new PDF
Code: Select all | Expand
// \samples\BYRON.PRG using gmail.com -> worked perfect
// ** Test program for email *** version by kapiabafwh@gmail.com
#include "FiveWin.ch"
FUNCTION Main()
SET CENTURY ON
SET DATE BRITISH
TestSend()
RETURN NIL
FUNCTION TestSend()
/*
LOCAL cServer := "smtp.gmail.com"
LOCAL cUserName := "Shipping@mycompany.com"
LOCAL cPassWord := "MyPassword"
LOCAL cFrom := "Shipping@mycompany.com"
LOCAL cSubject := DToC( Date() ) + "-" + Time() + ", Test for EMail"
LOCAL cToAddr := "byron.hopp@gmail.com"
LOCAL cCC := "bhopp@matrixcomputer.com"
LOCAL cBody := "Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
LOCAL cAttach := "c:\PdfFolder\Hopp.pdf" // any pdf can go here
LOCAL cCsvFile := ""
LOCAL lAttachCsv := .F.
LOCAL cLogFile := ""
*/
// It worked perfect Byron. Using: gmail.com
// nPort: SSL
// {"@gmail.com", "smtp.gmail.com", 465, .T. },;
LOCAL cServer := "smtp.gmail.com"
LOCAL cUserName := "kapiabafwh@gmail.com"
LOCAL cPassWord := "mylongpassword"
LOCAL cFrom := "kapiabafwh@gmail.com"
LOCAL cSubject := DToC( Date() ) + "-" + Time() + ", Test for EMail"
LOCAL cToAddr := "kapiabafwh@gmail.com"
LOCAL cCC := "bhopp@matrixcomputer.com"
LOCAL cBcc := "joao@pleno.com.br"
LOCAL cBody := "Byron Using GMAIL.COM: Email to test the SPF information in the EML. This email was authencated using the Shipping@mycompany.com user name."
// LOCAL cAttach := "c:\PdfFolder\Hopp.pdf" // any pdf can go here
LOCAL cAttach := "C:\ORCAMPDF\INSUMOS.PDF"
LOCAL cCsvFile := ""
LOCAL lAttachCsv := .F.
LOCAL cLogFile := ""
IF .NOT. FILE( cAttach )
MsgInfo( "Warning: PDF file, not located in source folder.", ;
"Warning: PDF file, not located in source folder." )
ENDIF
McsSendEMail( cServer, cUserName, cPassWord, cFrom, cSubject, cToAddr, cCC, cBcc, cBody, cAttach, cCsvFile, lAttachCsv, cLogFile )
RETURN NIL
FUNCTION McsSendEMail( cServer, cUserName, cPassWord, cFrom, cSubject, cToAddr, cCC, cBcc, cBody, cAttach, cCsvFile, lAttachCsv, cLogFile )
LOCAL oError, oCfg, oMsg, lRet := .T.
LOCAL cHtml := '<!DOCTYPE HTML PUBLIC "-/' + '/W3C/' + '/DTD HTML 4.0 Transitional/' + '/EN">'
cHtml += '<HTML><HEAD>'
cHtml += '<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>'
cHtml += '<META name=GENERATOR content="MSHTML 8.00.6001.18783">'
cHtml += '<STYLE></STYLE>'
cHtml += '</HEAD>'
cHtml += '<BODY bgColor=#ffffff>'
cHtml += '<DIV><FONT size=2 face=Courier New>' + cBody + '</FONT></DIV></BODY></HTML>'
/* // ??? Internal ???
IF Upper( AllTrim( cServer ) ) <> "smtp.gmail.com" .OR. ;
Upper( AllTrim( cUserName ) ) <> "shipping@frupco.com" .OR. ;
AllTrim( cPassWord ) <> "sC-93611"
MsgStop( "Please check the Email Credentials in the INI file, or call MCS.", "McsSendEmail" )
RETURN NIL
ENDIF
*/
Try
oCfg := CreateObject( "CDO.Configuration" )
WITH OBJECT oCfg:Fields
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ):Value := cServer // Servidor SMTP
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ):Value := 465 //<-(gmail) 587 // nPort
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusing" ):Value := 2 // Remote SMTP = 2, local = 1
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ):Value := .T. // lAut
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ):Value := .T. // lSSL // .F. Ou .T.(gmail)
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendusername" ):Value := TRIM(cUserName)
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ):Value := TRIM(cPassWord)
oCfg:Item( "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"):Value := 60
oCfg:Update()
END WITH
Catch oError
MsgStop( oError:Description, "CDO.Configuration - cEMailCfg:Fields:Update()" )
End Try
Try
oMsg := CREATEOBJECT ( "CDO.Message" )
WITH OBJECT oMsg
oMsg:Configuration := oCfg
oMsg:FROM := cFrom // chr(34) + "shipping@mycompany.com" + chr(34) + "<shipping@mycompany.com>"
oMsg:TO := cToAddr // "bhopp@matrixcomputer.com"
oMsg:Cc := cCC //""
oMsg:BCc := cBcc //""
oMsg:Subject := cSubject
oMsg:MDNRequested := .F.
oMsg:HTMLBody := cBody
IF File( cAttach )
oMsg:AddAttachment := cAttach
ENDIF
IF lAttachCsv .AND. File( cCsvFile )
oMsg:AddAttachment := cCsvFile
ENDIF
:Send()
END WITH
Catch oError
MsgInfo( "Could not send message" + ";" + ;
"Error: " + Transform( oError:GenCode, NIL ) + ";" + ;
"SubC: " + Transform( oError:SubCode, NIL ) + ";" + ;
"OSCode: " + Transform( oError:OsCode, NIL ) + ";" + ;
"SubSystem: " + Transform( oError:SubSystem, NIL ) + ";" + ;
"Message: " + oError:Description )
lRet := .F.
End Try
IF lRet
MsgInfo( "Message sent successfully. Congratulations.", ;
"Message sent successfully. Congratulations." )
ENDIF
oCfg := Nil
oMsg := Nil
RETURN NIL
// fin / end - 06/04/2022 - kapiabfwhgmail.com - Covid-19
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341