FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FASTREPORT - MAILExport
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
FASTREPORT - MAILExport
Posted: Sat Aug 29, 2009 02:29 PM

Hello Marco,

would you be so kind to show how to setup the attachment type
if you use

oFr:SetProperty("MAILExport", "ShowDialog",.f.)

Thanks in advance
Otto

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: FASTREPORT - MAILExport
Posted: Sat Aug 29, 2009 03:05 PM
Hi,
you can send a report via email using the standard FR mailsender. The big problem of this solution is that it requires the mail account (userid,password, smtp account etc) so I think it is a little complex for the end-use. See FRH manual for a sample.

I personally suggest you to use a more user-friendly solution as an ole connection to Outlook / MAPI in order FR simply open an email with the attachment directly in Outlook or into a MAPI compatible client.

you can make this adding this code at the end of the report
..
..
FrPrn:SetProperty("MailExport","ShowDialog",.f.)
FrPrn:SetEventHandler("MailExport","OnSendMail",{|ParamsArray|MySendMail(FrPrn,cPdfFile)})
..

and with these functions

Function MySendMail(FrPrn,cFile)
local aFiles

FrPrn:SetProperty("PDFExport","OpenAfterExport",.f.)
FrPrn:SetProperty("PDFExport", "ShowDialog", .f.)
FrPrn:SetProperty("PDFExport", "EmbeddedFonts", .f.)
FrPrn:SetProperty("PDFExport", "PrintOptimized", .t.)
FrPrn:DoExport("PDFExport")

aFiles:={}
aadd(aFiles,{cFile,cFile})
InteractiveMessage("","","",aFiles,.f.)
return("")

FUNCTION Interactivemessage()
paramet cSubject, cBody, aTo, aFiles, lDirectSend

LOCAL oOutLook,oMailItem,oRecip,oAttach,i,lOffice,lMailMancante

if lDirectSend=NIL
lDirectSend:=.f.
endif

if cSubject=NIL
cSubject:=""
endif
if cBody=NIL
cBody:=""
endif
if aFiles=NIL
aFiles:=array(0,0)
endif

lMailMancante:=.f.
for i:=1 to len(aTo)
if len(alltrim(aTo[i,2]))=0
lMailMancante:=.t.
endif
next

if lMailMancante
MsgStop("Indirizzo di posta elettronica assente","Attenzione")
return
endif

lOffice:=.t.
TRY
oOutLook := CreateObject( "Outlook.Application" )
oMailItem := oOutLook:CreateItem( 0 )
oRecip := oMailItem:Recipients
CATCH
lOffice:=.f.
END

if lOffice
for i:=1 to len(aTo)
oRecip:Add( aTo[i,2] )
next

oMailItem:Subject := cSubject

oMailItem:Body := cBody

if len(aFiles)>0
oAttach := oMailItem:Attachments
for i:=1 to len(aFiles)
oAttach:Add( aFiles[i,1] )
next
endif

if lDirectSend
oMailItem:Send()
else
oMailItem:display(.t.)
endif
else
for i:=1 to len(aTo)
aTo[i,1]:=alltrim(aTo[i,2])
aTo[i,2]:=alltrim(aTo[i,2])
next


oMail:=tMail():New( cSubject,cBody,,,,, .f., .t.,,aTo,aFiles)

ACTIVATE MAIL oMail
retcode:=oMail:nRetCode

endif
return
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 117
Joined: Mon Aug 13, 2007 05:22 PM
Re: FASTREPORT - MAILExport
Posted: Tue May 23, 2023 06:31 PM

Good afternoon.

Would there be a way to do something similar to generate a spreadsheet in Excel, not using the Fast routine for that, but using My ex routine:

FrPrn:SetProperty("XLSExport", "OpenExcelAfterExport" , .F.) // Abrir o excel

FrPrn:SetEventHandler("XLSExport","OnSendXls",{|ParamsArray|MySendXls(FrPrn,cPdfFile)})

Marcelo Ferro da Silveira

Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8

SqlLib /xMate/WS
Posts: 117
Joined: Mon Aug 13, 2007 05:22 PM
Re: FASTREPORT - MAILExport
Posted: Thu Jun 01, 2023 09:03 PM

Up

Marcelo Ferro da Silveira

Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8

SqlLib /xMate/WS

Continue the discussion