Interface IMailService
Service to send mail messages cross-platform.
Get this service in Razor or WebApi using e.g. GetService
[PublicApi]
public interface IMailService
Remarks
New in 2sxc 12.05
Methods
Create(NoParamOrder, 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.
MailMessage Create(NoParamOrder noParamOrder = default, 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
noParamOrder
NoParamOrderfrom
objectsender e-mail address in one of the following formats
- An e-mail string like "info@somwhere.com"
- An e-mail with name and address like "iJungleboy <ijungleboy@2sxc.org>"
- A single System.Net.Mail.MailAddress object
to
objectMain recipient(s) of the mail in one of the following formats
- all the formats as available in
from
- a CSV of such addresses like "info@a.com, info@b.com"
- An Array/List/IEnumerable of such strings
- An Array/List/IEnumerable of System.Net.Mail.MailAddress objects
- all the formats as available in
cc
objectCC recipient(s) of the mail, in the same format as
to
bcc
objectBCC recipient(s) of the mail, in the same format as
to
replyTo
objectReplyTo address(es) in the same format as
to
subject
stringThe main subject
body
stringThe body / contents of the e-mail - can be text or HTML
isHtml
bool?Set the body to be HTML - if not set, will auto-detect
encoding
EncodingEncoding 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.
attachments
objectOne or more attachments to include. Could be any of the following
Returns
- MailMessage
The newly created
MailMessage
object
Send(MailMessage)
Send a .net MailMessage
object using the settings configured in Dnn or Oqtane.
void Send(MailMessage message)
Parameters
message
MailMessageA prepared .net MailMessage object
Send(NoParamOrder, object, object, object, object, object, string, string, bool?, Encoding, object)
Quickly create and send an E-Mail.
void Send(NoParamOrder noParamOrder = default, 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
noParamOrder
NoParamOrderfrom
objectsender e-mail address in one of the following formats
- An e-mail string like "info@somwhere.com"
- An e-mail with name and address like "iJungleboy <ijungleboy@2sxc.org>"
- A single System.Net.Mail.MailAddress object
to
objectMain recipient(s) of the mail in one of the following formats
- all the formats as available in
from
- a CSV of such addresses like "info@a.com, info@b.com"
- An Array/List/IEnumerable of such strings
- An Array/List/IEnumerable of System.Net.Mail.MailAddress objects
- all the formats as available in
cc
objectCC recipient(s) of the mail, in the same format as
to
bcc
objectBCC recipient(s) of the mail, in the same format as
to
replyTo
objectReplyTo address(es) in the same format as
to
subject
stringThe main subject
body
stringThe body / contents of the e-mail - can be text or HTML
isHtml
bool?Set the body to be HTML - if not set, will auto-detect
encoding
EncodingEncoding 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.
attachments
objectOne or more attachments to include. Could be any of the following