Click or drag to resize

IEmailService Interface

Interface that implements an email service.

Namespace:  NetQuarry.Services
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
public interface IEmailService

The IEmailService type exposes the following members.

Properties
  NameDescription
Public propertyIsSendAsync
Returns true if the service delivers mail asynchronously.
Public propertyIsValidConfig
Returns true if the Smtp configuration is valid.
Public propertyServiceName
Returns the name of the email service.
Top
Methods
  NameDescription
Public methodConstructMessage
Constructs a MailMessage object using the specified destination parameters including optional attachments and Template.
Public methodSend(MailMessage)
Sends an e-mail message using arguments supplied in the properties of the MailMessage class.
Public methodSend(Message)
Sends an email message using arguments supplied in the properties of the Message class.
Public methodSend(MailMessage, SendEmailFlags)
Sends an e-mail message using arguments supplied in the properties of the MailMessage class and with SendEmailFlags options.
Public methodSend(MailMessage, SendEmailFlags, String)
Sends an e-mail message using arguments supplied in the properties of the MailMessage class, with SendEmailFlags options, and using a Template for the email composition.
Public methodSend(String, String, String, String)
Sends a text (not HTML) e-mail message using the specified basic parameters (from, to, subject, messageText).
Public methodSend(String, String, String, String, Boolean)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText).
Public methodSend(String, String, String, String, Boolean, String)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText) and using a Template for the email composition.
Public methodSend(String, String, String, String, String, String, Boolean)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText), with CC and BCC addresses, and using a Template for the email composition.
Public methodSend(String, String, String, String, String, String, Boolean, Attachment)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText), with CC and BCC addresses, and with attachments.
Public methodSend(String, String, String, String, String, String, Boolean, Attachment, SendEmailFlags)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText), with CC and BCC addresses, with attachments, and with SendEmailFlags options.
Public methodSend(String, String, String, String, String, String, Boolean, Attachment, SendEmailFlags, String)
Sends a text or HTML e-mail message using the specified basic parameters (from, to, subject, messageText), with CC and BCC addresses, with attachments, with SendEmailFlags options, and using a Template for the email composition.
Top
Examples
The following example shows how to obtain a reference to the email service and send a message using a template.
private void Send(IAppContext appContext, string sendToList, string templateName, NameValueCollection nameValues)
{
    ServiceInfos        svs = appContext.Services;
    IEmailService        mail = (IEmailService)svs.GetServiceInstance("SmtpMail");            
    NetQuarry.Template    tmpl = appContext.Templates[templateName];
    string                body;
    string                subject;

    if (tmpl == null)
        throw new ApplicationException(string.Format(this.TextItems.GetText(IDS_MISSING_TEMPLATE), templateName));

    body = tmpl.Replace(nameValues);
    subject = tmpl.TextItems.GetText("Subject");

    try
    {
        //--- leave the From field empty, it will default to the value configured in the studio
        mail.Send(string.Empty, sendToList, subject, body, true);
    }
    catch(Exception ex)
    {
        //--- log the error then re-throw
        DevLog.LogMessage("XIssue.Send", "sendMailError", ex);
        throw;
    }
}
See Also