• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API
Search Results for

    Show / Hide Table of Contents

    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 Source

    Create(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

    see Convention: Named Parameters

    object from

    sender 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
    object to

    Main 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
    object cc

    CC recipient(s) of the mail, in the same format as to

    object bcc

    BCC recipient(s) of the mail, in the same format as to

    object replyTo

    ReplyTo address(es) in the same format as to

    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

    • A System.Net.Mail.Attachment object
    • An IFile or an IFile object
    • An Array/IEnumerable of these
    Returns
    Type Description
    MailMessage

    The newly created MailMessage object

    | Improve this Doc View Source

    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

    | Improve this Doc View Source

    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

    see Convention: Named Parameters

    object from

    sender 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
    object to

    Main 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
    object cc

    CC recipient(s) of the mail, in the same format as to

    object bcc

    BCC recipient(s) of the mail, in the same format as to

    object replyTo

    ReplyTo address(es) in the same format as to

    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

    • A System.Net.Mail.Attachment object
    • An IFile or an IFile object
    • An Array/IEnumerable of these
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX