Sending Email from PowerBuilder: The Native SMTPClient Object
For years, sending email from PowerBuilder meant MAPI, an OLE automation server, or a third-party DLL. Since PowerBuilder 2022 R2 there is a native way: the SMTPClient and MimeMessage objects, speaking SMTP/SMTPS directly — with STARTTLS and modern OAuth2 authentication, which Microsoft 365 and Gmail increasingly require. Here is how it works and why it matters.
Aug 2026
PowerBuilder can send email natively, without a third-party library — and, importantly, with the modern authentication that Microsoft 365 and Gmail now expect. Since PowerBuilder 2022 R2, the SMTPClient and MimeMessage objects talk SMTP and SMTPS directly, support STARTTLS and OAuth2 (XOAUTH2), and can send in the background. For any application that still emails through MAPI, an Outlook automation server or an ageing SMTP DLL, this is the piece worth adopting.
What SMTPClient replaces
For most of PowerBuilder's life, sending mail meant one of three awkward routes: MAPI (fragile, tied to an installed mail client), an OLE automation server driving Outlook (slow, security-prompt-prone), or a third-party SMTP component you had to license and deploy. The native objects remove that dependency: MimeMessage holds the message — subject, recipients, an HTML or plain-text body, and attachments — and SMTPClient connects to your mail server and sends it.
Security and authentication — the part that matters most
The reason to care about this now is authentication. Microsoft 365 and Gmail are retiring username-and-password (Basic) authentication in favour of OAuth2. Older PowerBuilder email code that logs in with a stored password is on borrowed time. The SMTPClient handles the modern path:
| Area | Supported |
|---|---|
| Protocols | SMTP, SMTPS |
| Transport security | None (plain), STARTTLS, Auto STARTTLS |
| Authentication | None, Auto, CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2 |
| Message format | HTML and plain text |
| Sending | Synchronous or asynchronous; via proxy if needed |
For Microsoft 365 or Gmail you use XOAUTH2: obtain an access token from the identity provider (Microsoft Entra ID or Google) and set it on the SMTPClient's XOAuth2AccessToken property. Getting a real browser-based OAuth flow into a desktop app is exactly where the WebBrowser / WebView2 control earns its place.
The objects at a glance
| SMTPClient member | Purpose |
|---|---|
| Host, Port | Mail server address and port |
| AuthType, UserName, Password, XOAuth2AccessToken | How the client authenticates |
| EnableTLS, SecureProtocol, IgnoreServerCertificate | Transport security and certificate handling |
| Message | The MimeMessage to send |
| Send(), SendAsync(), SendAsyncCancel() | Send synchronously, in the background, or cancel |
| SetProxy(), LogFile() | Route through a proxy; log the exchange for diagnosis |
| OnSendFinished (event) | Fires when an async send completes; reports errors |
Send without freezing the UI
A synchronous Send() blocks until the server responds — fine for a one-off, painful when a user is waiting or you are sending several. Use SendAsync() to hand the work off and let the OnSendFinished event tell you the outcome, including any error, when it is done. SendAsyncCancel() stops a pending send. For anything user-facing — a “send confirmation” button, a batch of notices — async is the right default.
Deployment
Native email needs two runtime files shipped with your application: pbsmtpclient.dll and libcurl.dll. That is the whole footprint — no mail client, no automation server, no external component to license. The objects were introduced in 2022 R2 and refined in the releases since, including 2025 R2.
Frequently asked
Can PowerBuilder send email without a third-party library?
Yes. Since PowerBuilder 2022 R2 there is native email support through the SMTPClient and MimeMessage objects. They speak SMTP and SMTPS directly, so you no longer need MAPI, an Outlook OLE automation server or a third-party SMTP DLL.
Does the SMTPClient support Microsoft 365 and Gmail modern authentication?
Yes. The SMTPClient supports XOAUTH2 authentication — you set the XOAuth2AccessToken property with a token obtained from your identity provider. That is what Microsoft 365 (Entra ID) and Gmail increasingly require now that Basic Authentication is being retired. It also supports LOGIN, PLAIN, CRAM-MD5, NTLM and Auto.
Is the connection encrypted?
It can be. The SMTPClient supports SMTPS and TLS via STARTTLS or Auto STARTTLS (with EnableTLS and SecureProtocol properties), plus certificate-handling options. Plain-text (None) is available but should only be used on a trusted internal relay.
Can it send email in the background so the UI does not freeze?
Yes. Use SendAsync() to send asynchronously and handle the OnSendFinished event to learn the result (including any error); SendAsyncCancel() cancels a pending send. Send() is the synchronous equivalent.
PowerBuilder notes, now and then
New writing on upgrades, databases and modernization — a few times a month, nothing more.