SendDocumentByMail
Document management
Description
Saves the currently loaded document to an isolated temporary directory and sends the PDF as an attachment through MailProvider
When MailProvider is nil, Windows uses the built-in CDO SMTP provider; other platforms must install an IPDFlibMailProvider implementation before calling this method
The temporary PDF and its directory are removed after the provider returns, whether delivery succeeds or fails; the attachment name is reduced to a file name and characters that are invalid on Windows are replaced with underscores
Syntax
Delphi
Function TPDFlib.SendDocumentByMail(Const SMTPHost: WideString; SMTPPort, UseSSL: Integer; Const UserName, Password, FromAddr, ToList, CCList, BCCList, MailSubject, MailBody, AttachmentName: WideString): Integer;Parameters
| SMTPHost | SMTP server host name; required even when a custom provider interprets it differently |
|---|---|
| SMTPPort | Server port; zero selects 25 without SSL or 465 with SSL |
| UseSSL | Set to 1 to request an SSL connection, or 0 otherwise |
| UserName | Authentication name; an empty value requests unauthenticated delivery |
| Password | Authentication password passed only to the provider |
| FromAddr | Sender address |
| ToList | Required recipient list using comma or semicolon separators |
| CCList | Optional carbon-copy recipient list |
| BCCList | Optional blind-carbon-copy recipient list |
| MailSubject | Message subject |
| MailBody | Plain-text message body |
| AttachmentName | Attachment display name; an empty value selects document.pdf |
Return values
| 0 | Validation, temporary save or provider delivery failed; call GetLastMailError for details |
|---|---|
| 1 | The provider accepted the message |