<commit_before>﻿using MailService.Core.Configuration;
using MailService.Core.Models;
using MailService.Core.Response;
using System;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;

namespace MailService.Core.Services
{
    public class MailService : IMailService
    {
        private MailServiceOptions _options = null;
        public MailService(MailServiceOptions options)
        {
            _options = options;
        }

        public async Task<MailSentResult> SendAsync(string profileName, Mail mail)
        {

            var profile = _options.Profiles[profileName];

            if (profile == null)
            {
                return await Task.FromResult(new MailSentResult
                {
                    Succeeded = false,
                    Error = "Profile name not found"
                });
            }

            SmtpClient client = new SmtpClient(profile.Host, profile.Port)
            {
                EnableSsl = profile.SSL,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(profile.UserName, profile.Password)
            };

            MailMessage mailMessage = new MailMessage
            {
                From = new MailAddress(profile.UserName)
            };
            foreach (var reciever in mail.To)
            {
                mailMessage.To.Add(reciever);
            }

            mailMessage.IsBodyHtml = mail.IsBodyHtml;
            mailMessage.Body = mail.Body;
            mailMessage.Subject = mail.Subject;

            try
            {
                await client.SendMailAsync(mailMessage);

                return await Task.FromResult(new MailSentResult
                {
                    Succeeded = true
                });
            }
            catch (Exception ex)
            {
                return await Task.FromResult(new MailSentResult
                {
                    Succeeded = false,
                    Error = "Mail sent failed"
                });
            }
        }
    }
}<commit_msg>code beautify<commit_after>﻿using MailService.Core.Configuration;
using MailService.Core.Models;
using MailService.Core.Response;
using System;
using System.Net;
using System.Net.Mail;
using System.Threading.Tasks;

namespace MailService.Core.Services
{
    public class MailService : IMailService
    {
        private MailServiceOptions _options = null;
        public MailService(MailServiceOptions options)
        {
            _options = options;
        }

        public async Task<MailSentResult> SendAsync(string profileName, Mail mail)
        {

            var profile = _options.Profiles[profileName];

            if (profile == null)
            {
                return await Task.FromResult(new MailSentResult
                {
                    Succeeded = false,
                    Error = "Profile name not found"
                });
            }

            SmtpClient client = new SmtpClient(profile.Host, profile.Port)
            {
                EnableSsl = profile.SSL,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(profile.UserName, profile.Password)
            };

            MailMessage mailMessage = new MailMessage
            {
                From = new MailAddress(profile.UserName)
            };
            foreach (var reciever in mail.To)
            {
                mailMessage.To.Add(reciever);
            }

            mailMessage.IsBodyHtml = mail.IsBodyHtml;
            mailMessage.Body = mail.Body;
            mailMessage.Subject = mail.Subject;
            MailSentResult mr = null;

            try
            {
                await client.SendMailAsync(mailMessage);
                mr = new MailSentResult
                {
                    Succeeded = true
                };

                return await Task.FromResult(mr);
            }
            catch (Exception ex)
            {
                mr = new MailSentResult
                {
                    Succeeded = false,
                    Error = "Mail sent failed"
                };

                return await Task.FromResult(mr);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06961875443997158, 'fraction_numerical': 0.0, 'mean_word_length': 1.3324130314743237, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5382174', 'n_tokens_mistral': 1044, 'n_tokens_neox': 977, 'n_words': 222}