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 : INeedsDynamicCodeRoot
Remarks
New in 2sxc 12.05
Methods
| Improve this Doc View SourceCreate(String, Object, Object, Object, Object, Object, String, String, Nullable<Boolean>, 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://r.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 = default(bool? ), Encoding encoding = null, object attachments = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.Object | from | sender e-mail address in one of the following formats
|
System.Object | to | Main recipient(s) of the mail in one of the following formats
|
System.Object | cc | CC recipient(s) of the mail, in the same format as |
System.Object | bcc | BCC recipient(s) of the mail, in the same format as |
System.Object | replyTo | ReplyTo address(es) in the same format as |
System.String | subject | The main subject |
System.String | body | The body / contents of the e-mail - can be text or HTML |
System.Nullable<System.Boolean> | isHtml | Set the body to be HTML - if not set, will auto-detect |
System.Text.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. |
System.Object | attachments | One or more attachments to include. Could be any of the following |
Returns
Type | Description |
---|---|
System.Net.Mail.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 |
---|---|---|
System.Net.Mail.MailMessage | message | A prepared .net MailMessage object |
Send(String, Object, Object, Object, Object, Object, String, String, Nullable<Boolean>, Encoding, Object)
Quickly create and send an E-Mail.
Declaration
void Send(string noParamOrder = "Params must be named (https://r.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 = default(bool? ), Encoding encoding = null, object attachments = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | noParamOrder | |
System.Object | from | sender e-mail address in one of the following formats
|
System.Object | to | Main recipient(s) of the mail in one of the following formats
|
System.Object | cc | CC recipient(s) of the mail, in the same format as |
System.Object | bcc | BCC recipient(s) of the mail, in the same format as |
System.Object | replyTo | ReplyTo address(es) in the same format as |
System.String | subject | The main subject |
System.String | body | The body / contents of the e-mail - can be text or HTML |
System.Nullable<System.Boolean> | isHtml | Set the body to be HTML - if not set, will auto-detect |
System.Text.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. |
System.Object | attachments | One or more attachments to include. Could be any of the following |