Interface IMailService
Service to send mail messages cross-platform.
Get this service in Razor or WebApi using GetService
Namespace: ToSic.Sxc.Services
Assembly: ToSic.Sxc.dll
Syntax
[PublicApi]
public interface IMailService
Remarks
New in 2sxc 12.05
Methods
| Improve this Doc View SourceCreate(string, object, object, object, object, object, string, string, bool?, Encoding, object)
Quickly create a MailMessage object for further modification and then sending using Send(MailMessage) If you don't want to modify the resulting object, skip this and use the direct-send method.
Declaration
MailMessage Create(string noParamOrder = "Params must be named (https://go.2sxc.org/named-params)", object from = null, object to = null, object cc = null, object bcc = null, object replyTo = null, string subject = null, string body = null, bool? isHtml = null, Encoding encoding = null, object attachments = null)
Parameters
Type | Name | Description |
---|---|---|
string | noParamOrder | |
object | from | sender e-mail address in one of the following formats
|
object | to | Main recipient(s) of the mail in one of the following formats
|
object | cc | CC recipient(s) of the mail, in the same format as |
object | bcc | BCC recipient(s) of the mail, in the same format as |
object | replyTo | ReplyTo address(es) in the same format as |
string | subject | The main subject |
string | body | The body / contents of the e-mail - can be text or HTML |
bool? | isHtml | Set the body to be HTML - if not set, will auto-detect |
Encoding | encoding | Encoding of subject and body - if not set, will default to UTF8. If you need different encodings on subject and body, set it on the resulting object. |
object | attachments | One or more attachments to include. Could be any of the following |
Returns
Type | Description |
---|---|
MailMessage | The newly created |
Send(MailMessage)
Send a .net MailMessage
object using the settings configured in Dnn or Oqtane.
Declaration
void Send(MailMessage message)
Parameters
Type | Name | Description |
---|---|---|
MailMessage | message | A prepared .net MailMessage object |
Send(string, object, object, object, object, object, string, string, bool?, Encoding, object)
Quickly create and send an E-Mail.
Declaration
void Send(string noParamOrder = "Params must be named (https://go.2sxc.org/named-params)", object from = null, object to = null, object cc = null, object bcc = null, object replyTo = null, string subject = null, string body = null, bool? isHtml = null, Encoding encoding = null, object attachments = null)
Parameters
Type | Name | Description |
---|---|---|
string | noParamOrder | |
object | from | sender e-mail address in one of the following formats
|
object | to | Main recipient(s) of the mail in one of the following formats
|
object | cc | CC recipient(s) of the mail, in the same format as |
object | bcc | BCC recipient(s) of the mail, in the same format as |
object | replyTo | ReplyTo address(es) in the same format as |
string | subject | The main subject |
string | body | The body / contents of the e-mail - can be text or HTML |
bool? | isHtml | Set the body to be HTML - if not set, will auto-detect |
Encoding | encoding | Encoding of subject and body - if not set, will default to UTF8. If you need different encodings on subject and body, set it on the resulting object. |
object | attachments | One or more attachments to include. Could be any of the following |