Integrations

Sending and Reading Email with GPAL.Mail

GPAL.Mail sends and receives email through standard SMTP, IMAP, and POP3. The same fluent settings-then-action pattern as everything else, so notifying a team or watching for a reply is just another step in a workflow.

Server Settings

GPAL.Mail starts with server settings: a server name and optional port for SMTP (outgoing), and optionally IMAP or POP3 (incoming). You configure whichever direction the workflow needs and add credentials once. That configured object is then reused for every send or receive operation in the workflow.

var mail = GPAL.Mail

.WithSMTPServerName("smtp.example.com")

.WithUserName("automation@example.com")

.WithPassword("...")

.ToGPALObject();

Composing and Sending

Composing a message is a short fluent chain: set the from, to, CC, and BCC addresses, the subject, the body, and any attachments. Each address field accepts a single address, a list of addresses, or an address with a display name. A plain file path works for attachments. Send transmits the message using the configured SMTP server.

mail

.WithFromEmailAddress("automation@example.com")

.WithToEmailAddress("team@example.com")

.WithSubject("Nightly report ready")

.WithBody("The nightly export finished. See attached.")

.WithAttachment("report.csv")

.Send();

Receiving and Sending Again

Receive retrieves messages from the configured IMAP or POP3 server, for workflows that wait on a reply or watch a shared inbox. Clear resets the envelope -- from, to, subject, body, and attachments -- while keeping the server settings, so the same mail object can send a sequence of different messages without rebuilding the connection each time. WithName assigns a friendly identifier to a mail instance for logging, useful when a workflow uses more than one.

// Send one message per row, reusing the same connection

foreach (var row in recipients)

{

mail

.WithToEmailAddress(row["Email"])

.WithSubject("Your weekly summary")

.WithBody(row["Summary"])

.Send();

mail.Clear();

}