Table of Contents

Class SendMailOptions

Namespace
Quartz.Jobs
Assembly
Quartz.Jobs.dll

The message SendMailJob sends, and the SMTP server it goes through.

public sealed record SendMailOptions : IEquatable<SendMailOptions>
Inheritance
SendMailOptions
Implements
Inherited Members

Remarks

The job is configured through its JobDataMap, and those keys are the persisted contract — this type is the named way to write and read them. UsingSendMailOptions<TConfigurator>(TConfigurator, SendMailOptions) writes them, FromJobData(JobDataMap) reads them back, and job data written by hand or by an earlier version reads the same either way.

There is deliberately no SMTP user name or password here. Job data is durable: a persistent job store writes it to QRTZ_JOB_DETAILS, every node in a cluster reads it, the dashboard shows it, and any support-bundle export of that table carries it. Register an ICredentialsByHost — a NetworkCredential or a CredentialCache — with the container instead, and the job authenticates with it. The smtp_username and smtp_password keys still work so that a job scheduled by an earlier version keeps sending, and the job warns when it uses them.

Properties

CcRecipient

The address to copy the mail to, or null for none.

public string? CcRecipient { get; init; }

Property Value

string

EnableSsl

Whether to negotiate TLS with the SMTP server. false by default, which is SmtpClient's own default.

public bool EnableSsl { get; init; }

Property Value

bool

Remarks

Off by default because turning it on fails outright against a server that does not offer TLS, and a relay on the same host that has been taking this job's mail for years would stop. Turn it on for anything that crosses a network you do not own, and for anything that authenticates: SMTP AUTH LOGIN is base64, not encryption.

Encoding

The name of the encoding the subject and body are sent in, such as utf-8, or null for the default.

public string? Encoding { get; init; }

Property Value

string

Message

The message body.

public required string Message { get; init; }

Property Value

string

Recipient

The address to send the mail to.

public required string Recipient { get; init; }

Property Value

string

ReplyTo

The address the message asks replies to go to, or null to leave it to the sender.

public string? ReplyTo { get; init; }

Property Value

string

Sender

The address to claim the mail is from.

public required string Sender { get; init; }

Property Value

string

SmtpHost

The host name of the SMTP server to send through.

public required string SmtpHost { get; init; }

Property Value

string

SmtpPort

The port to reach the SMTP server on, or null for the client's default.

public int? SmtpPort { get; init; }

Property Value

int?

Subject

The subject line.

public required string Subject { get; init; }

Property Value

string

Methods

FromJobData(JobDataMap)

Reads the options out of a job's data.

public static SendMailOptions FromJobData(JobDataMap data)

Parameters

data JobDataMap

The job data to read, normally MergedJobDataMap.

Returns

SendMailOptions

Exceptions

ArgumentException

One of the required keys is absent or empty.

ToJobData()

Writes the options as the job data keys SendMailJob reads.

public JobDataMap ToJobData()

Returns

JobDataMap