I want it to behave like when using the "Export to pdf" dialog (FrPrn:SetProperty("PDFExport", "ShowDialog", .t.)):
This is code:
- Code: Select all Expand view RUN
Function PdfAndMail(mSubject,mTo,mCc)
mFileName=cOsnDir+"\Pdf\" + rtrim(mSubject) + ".pdf"
FrPrn:SetProperty("PDFExport", "Title", mSubject)
FrPrn:SetProperty("PDFExport", "Author", mKorisnik)
FrPrn:SetProperty("PDFExport", "Subject", RptHead->Naziv)
FrPrn:SetProperty("PDFExport", "FileName", mFileName)
FrPrn:SetProperty("PDFExport", "OpenAfterExport", .t.)
FrPrn:SetProperty("PDFExport", "ShowDialog", .t.)
FrPrn:SetProperty("PDFExport", "PrintOptimized", .t.)
FrPrn:PrepareReport()
FrPrn:SetProperty("MailExport", "ShowExportDialog", .f.)
FrPrn:SetProperty("MailExport", "ShowDialog",.f.)
FrPrn:SetEventHandler("MailExport","OnSendMail",{|ParamsArray|MySendMail(mSubject,mTextBody,mTo,mCc,mFileName,.f.,FrPrn)})
FrPrn:ShowReport()
FrPrn:DestroyFR()
function MySendMail()
paramet cSubject, cBody, aTo, aCc, aFiles, lDirectSend, oFrPrn
LOCAL cTasks,oAttach
LOCAL OutlFound := .F.
FrPrn:SetProperty("PDFExport","OpenAfterExport",.f.)
FrPrn:SetProperty("PDFExport", "ShowDialog", .f.)
FrPrn:DoExport("PDFExport")
cTasks := GetTasks()
FOR i=1 TO LEN(cTasks)
IF AT("OUTLOOK",UPPER(cTasks[i])) <> 0
OutlFound := .T.
i := LEN(cTasks)
ENDIF
NEXT
IF !OutlFound ; ShellExecute(,"Open","Outlook",,,1) ; ENDIF
TRY
oOutLook := CreateObject("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
EmSend := .T.
CATCH
TRY
oOutLook := CreateObject("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
EmSend := .T.
CATCH
EmSend := .F.
END
END
IF EmSend
oMail := oOutLook:CreateItem(0)
oMail:Subject := cSubject
oMail:Body := cBody
oMail:To := aTo
oMail:CC := aCc
oMail:BCC := ""
oAttach := oMail:Attachments
oAttach:Add(aFiles)
oMail:Display = .T.
*oMail:Send()
ENDIF
FrPrn:SetProperty("PDFExport", "OpenAfterExport", .t.)
FrPrn:SetProperty("PDFExport", "ShowDialog", .t.)
Return ("")