Using MAPI eMail without Preview
Hi,
i??m trying to send email with the MAPI functionality.
It works fine when using the report.show function. But i want FastReport to open a new eMail (from Thunderbird) attached with the report as PDF.
Also it would be fine to add Address, Subject and Message Text programmatically.
Every code snipped i??ve found work??s only without MAPI in SMTP mode.
Any idea?
i??m trying to send email with the MAPI functionality.
FastReport.Utils.Config.EmailSettings.UseMAPI = True
It works fine when using the report.show function. But i want FastReport to open a new eMail (from Thunderbird) attached with the report as PDF.
Also it would be fine to add Address, Subject and Message Text programmatically.
Every code snipped i??ve found work??s only without MAPI in SMTP mode.
Any idea?
This discussion has been closed.
Comments
Try this in your form:
IntPtr handle = this.Handle;
It will return the handle of the form and pass it to MAPI.SendMail
thanks a lot! This works.
Hello!
As suggested in the thread, use the built-in helper `FastReport.Export.Email.MAPI.SendMail(this.Handle, new[] { pdfPath }, subject, body, new[] { recipientName }, new[] { recipientEmail })` after the programmatic `PDFExport`.
Or use the `EmailExport` class with `Config.EmailSettings.UseMAPI = true;`:
using var email = new FastReport.Export.Email.EmailExport { Address = “client@example.com”, Subject = “Report”, MessageBody = “See attached PDF”, Export = new FastReport.Export.Pdf.PDFExport() }; email.Account.UseMAPI = true; email.SendEmail(report);We’re glad the issue has been resolved!