public IOptionObject2015 Execute()
        {
            logger.Debug("Executing {command}.", nameof(SendEmailCommand));

            string      to          = "*****@*****.**";
            string      from        = "*****@*****.**";
            string      subject     = "Example Send Email Command";
            string      body        = @"This is our example email to demonstrate sending of emails from ScriptLink.";
            MailMessage mailMessage = new MailMessage(from, to)
            {
                IsBodyHtml = false,
                Subject    = subject,
                Body       = body
            };

            _smtpService.Send(mailMessage);
            _smtpService.Dispose();

            return(_optionObject.ToReturnOptionObject(ErrorCode.None, "Email sent."));
        }
Exemplo n.º 2
0
        public OptionObject2015 Execute()
        {
            // Get Email Address
            string emailAddress = GetEmailAddress();

            logger.Debug("Attempting to send an email to {emailAddress}.", emailAddress);

            if (string.IsNullOrEmpty(emailAddress))
            {
                logger.Error("A valid email was not provided to {command}.", nameof(SendTestEmailCommand));
            }
            else
            {
                // Create MailMessage
                MailMessage mailMessage = GetMailMessage(emailAddress);

                // Send MailMessage
                _smtpService.Send(mailMessage);
                _smtpService.Dispose();
            }

            return(_optionObject2015.ToReturnOptionObject(ErrorCode.Informational, "SendTestEmailCommand executed."));
        }
Exemplo n.º 3
0
 public void Dispose()
 {
     _smtpService?.Dispose();
 }