Page 1 of 1

FASTREPORT - MAILExport

Posted: Sat Aug 29, 2009 2:29 pm
by Otto
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

Re: FASTREPORT - MAILExport

Posted: Sat Aug 29, 2009 3:05 pm
by Marco Turco
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

Re: FASTREPORT - MAILExport

Posted: Tue May 23, 2023 6:31 pm
by marca
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)})

Re: FASTREPORT - MAILExport

Posted: Thu Jun 01, 2023 9:03 pm
by marca
Up