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

SMTPHostSMTP server host name; required even when a custom provider interprets it differently
SMTPPortServer port; zero selects 25 without SSL or 465 with SSL
UseSSLSet to 1 to request an SSL connection, or 0 otherwise
UserNameAuthentication name; an empty value requests unauthenticated delivery
PasswordAuthentication password passed only to the provider
FromAddrSender address
ToListRequired recipient list using comma or semicolon separators
CCListOptional carbon-copy recipient list
BCCListOptional blind-carbon-copy recipient list
MailSubjectMessage subject
MailBodyPlain-text message body
AttachmentNameAttachment display name; an empty value selects document.pdf

Return values

0Validation, temporary save or provider delivery failed; call GetLastMailError for details
1The provider accepted the message