The filename is what is shown to the user, not the file on your sending computer. It should NOT have a path in it.
in the html, use img src="cid:ID_GIVEN_HERE"
Gets the current html body, if any.
Sends via a given SMTP relay
Adds a custom header to the message. The header name should not include a colon and must not duplicate a header set elsewhere in the class; for example, do not use this to set To, and instead use the to field.
Sets the HTML body to the mail, which can support rich text, inline images (see addInlineImage), etc.
Sets the plain text body of the email. You can also separately call setHtmlBody to set a HTML body.
Gets and sets the current text body.
Returns the MIME formatted email string, including encoded attachments
Recipients of the message. You can use operator ~= to add people to this list, or you can also use addRecipient to achieve the same result.
Represents the From: and Reply-To: header values in the email.
The In-Reply-to: header value. This should be set to the same value as the Message-ID header from the message you're replying to.
If you use the send method with an SMTP server, you don't want to change this. While RFC 2045 mandates CRLF as a lineseperator, there are some edge-cases where this won't work. When passing the E-Mail string to a unix program which handles communication with the SMTP server, some (i.e. qmail) expect the system lineseperator (LF) instead. Notably, the google mail REST API will choke on CRLF lineseps and produce strange emails (as of 2024).
Represents the From: and Reply-To: header values in the email.
The Subject: header value in the email.
Recipients of the message. You can use operator ~= to add people to this list, or you can also use addRecipient to achieve the same result.
To use:
auto message = new EmailMessage(); message.to ~= "someuser@example.com"; message.from = "youremail@example.com"; message.subject = "My Subject"; message.setTextBody("hi there"); //message.toString(); // get string to send externally message.send(); // send via some relay // may also set replyTo, etc
This class got an API overhaul on May 13, 2024. Some undocumented members were removed, and some public members got changed (albeit in a mostly compatible way).
For OUTGOING email