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
FASTREPORT - MAILExport
- Otto
- Posts: 6396
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 8 times
- Been thanked: 1 time
- Contact:
FASTREPORT - MAILExport
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Re: FASTREPORT - MAILExport
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
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
Marco Turco
SOFTWARE XP LLP
Re: FASTREPORT - MAILExport
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)})
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
Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8
SqlLib /xMate/WS
Re: FASTREPORT - MAILExport
Up
Marcelo Ferro da Silveira
Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8
SqlLib /xMate/WS
Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8
SqlLib /xMate/WS