Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="provider"></param>
        public void SetProperty(EmailServiceProvider provider)
        {
            String serverName = "";
            Int32  port       = Default.Port;
            SmtpEncryptedCommunication encryptedCommunication = SmtpEncryptedCommunication.None;

            switch (provider)
            {
            case EmailServiceProvider.Gmail: serverName = "smtp.gmail.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;

            case EmailServiceProvider.Outlook: serverName = "smtp-mail.outlook.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;

            case EmailServiceProvider.YahooMail: serverName = "smtp.mail.yahoo.com"; encryptedCommunication = SmtpEncryptedCommunication.Ssl; break;

            case EmailServiceProvider.AolMail: serverName = "smtp.aol.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;

            case EmailServiceProvider.ZohoMail: serverName = "smtp.zoho.com"; encryptedCommunication = SmtpEncryptedCommunication.Ssl; break;

            default: throw new InvalidOperationException();
            }
            this.ServerName = serverName;

            switch (encryptedCommunication)
            {
            case SmtpEncryptedCommunication.None: port = 25; break;

            case SmtpEncryptedCommunication.Ssl: port = 465; break;

            case SmtpEncryptedCommunication.Tls: port = 587; break;

            default: throw new InvalidOperationException();
            }
            this.Port = port;
            this.EncryptedCommunication = encryptedCommunication;
        }
 /// <summary>
 /// Initialises a new instance of the Skycap.Settings.AddAccountsSettingsEmailServiceProvider class.
 /// </summary>
 /// <param name="emailServiceProvider">The email service provider.</param>
 /// <param name="imageSource">The image source.</param>
 public AddAccountsSettingsEmailServiceProvider(EmailServiceProvider emailServiceProvider, string imageSource)
     : base()
 {
     // Initialise local variables
     EmailServiceProvider = emailServiceProvider;
     ImageSource          = imageSource;
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 public SmtpClient(EmailServiceProvider provider, String userName, String password)
     : this()
 {
     this.SetProperty(provider);
     this.UserName = userName;
     this.Password = password;
 }
Пример #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 public ImapClient(EmailServiceProvider provider, String userName, String password)
     : this("")
 {
     this.SetProperty(provider);
     this.UserName = userName;
     this.Password = password;
 }
Пример #5
0
        public async Task <IHttpActionResult> SubmitOrder(JerseyOrder order)
        {
            if (ModelState.IsValid)
            {
                if (order.PromoCode != null)
                {
                    order.PromoCode = order.PromoCode.ToUpperInvariant();
                }

                _dbContext.JerseyOrders.Add(order);

                try
                {
                    _dbContext.SaveChanges();
                }
                catch (DbUpdateException e)
                {
                    System.Diagnostics.Trace.TraceError("Order submit exception: " + e.Message);
                    return(BadRequest("Something went wrong..."));
                }

                try
                {
                    await _dbContext.Entry(order).Reference(o => o.Promo).LoadAsync().ConfigureAwait(false);

                    decimal discount = baseDiscount;
                    if (order.Promo != null)
                    {
                        discount += order.Promo.Discount;
                    }

                    StringBuilder builder = new StringBuilder();
                    builder.Append($@"Здравейте {order.FirstName} {order.LastName},
                                <p>Успешно получихме вашата поръчка. Очаквайте обаждане на посоченият от вас телефонен номер за потвърждение!</p>
                                <p>Детайли за вашата поръчка:</p>");
                    foreach (JerseyDetails jersey in order.Jerseys)
                    {
                        builder.Append($"<p>{Util.JerseyCutNames[jersey.Cut]} тениска, размер {Util.JerseySizeNames[jersey.Size]}</p>");
                    }
                    builder.Append($"Обща цена: {order.Jerseys.Count * baseJerseyPrice * (1 - discount) + 5}лв.");
                    builder.Append(@"<p>Поздрави от екипа на Bellum Gens!</p>
                                <a href='https://eb-league.com' target='_blank'>https://eb-league.com</a>");

                    await EmailServiceProvider.SendNotificationEmail(order.Email, "Поръчката ви е получена", builder.ToString()).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.TraceError("Order submit exception: " + e.Message);
                }
                return(Ok(order));
            }
            return(BadRequest("Order couldn't be validated..."));
        }
        /// <summary>
        /// Occurs when the currently selected "Email Service Provider" changes.
        /// </summary>
        /// <param name="sender">The object that raised the event (lbEmailServiceProvider).</param>
        /// <param name="e">The event arguments (SelectionChangedEventArgs).</param>
        private void lbEmailServiceProvider_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbEmailServiceProvider.SelectedItem != null)
            {
                // Prepare configure account flyout
                EmailServiceProvider selectedEmailServiceProvider = ((AddAccountsSettingsEmailServiceProvider)lbEmailServiceProvider.SelectedItem).EmailServiceProvider;
                EmailServiceDialog   emailServiceDialog           = new EmailServiceDialog();
                emailServiceDialog.EmailServiceProvider = selectedEmailServiceProvider;
                emailServiceDialog.Show();

                // Hide add an account flyout
                cfAddAnAccountFlyout.IsOpen = false;
            }
        }
Пример #7
0
        public async Task <IHttpActionResult> Generate([FromBody] dynamic inparams)
        {
            long     id         = inparams.id;
            DateTime generation = inparams.generation;

            var result = await _billingService.GenerateBill(id, generation);

            foreach (var item in result)
            {
                try
                {
                    var    emailProvider = new EmailServiceProvider();
                    string monthName     = ProgramCommon.GetMonthName(item.Month);
                    await emailProvider.GenerateBills(item.Name, item.Email, item.Amount, monthName, item.Year);
                }
                catch (Exception) { }
            }

            return(Ok());
        }
Пример #8
0
        static void Main(string[] args)
        {
            _emailProvider = new EmailServiceProvider();

            #region Local
            //while (true)
            //{
            //    var czas = DateTime.Now;
            //    Console.WriteLine(czas);
            //    if (czas.ToString("HH:mm") == "13:05")
            //    {
            //        Console.WriteLine("Wysyłam maile o godzinie" + czas);
            //        _emailProvider.SendNewsletterToSubscribers();
            //        Thread.Sleep(70000);
            //    }
            //}
            #endregion

            #region Azure
            _emailProvider.SendNewsletterToSubscribers();
            #endregion
        }
Пример #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="provider"></param>
        public void SetProperty(EmailServiceProvider provider)
        {
            String serverName = "";

            switch (provider)
            {
            case EmailServiceProvider.Gmail: serverName = "pop.gmail.com"; break;

            case EmailServiceProvider.Outlook: serverName = "pop-mail.outlook.com"; break;

            case EmailServiceProvider.YahooMail: serverName = "pop.mail.yahoo.com"; break;

            case EmailServiceProvider.AolMail: serverName = "pop.aol.com"; break;

            case EmailServiceProvider.ZohoMail: serverName = "pop.zoho.com"; break;

            default: throw new InvalidOperationException();
            }
            this.ServerName = serverName;
            this.Port       = 995;
            this.Ssl        = true;
        }
Пример #10
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Data.AccountSettingsData class.
 /// </summary>
 /// <param name="accountName">The account name.</param>
 /// <param name="emailService">The email service.</param>
 /// <param name="emailServiceProvider">The email service provider.</param>
 /// <param name="displayName">The email display name.</param>
 /// <param name="emailAddress">The email address.</param>
 /// <param name="userName">The user name.</param>
 /// <param name="password">The email password.</param>
 /// <param name="incomingMailServer">The incoming mail server.</param>
 /// <param name="incomingMailServerPort">The incoming mail server port.</param>
 /// <param name="isIncomingMailServerSsl">A value indicating whether the incoming mail server uses ssl.</param>
 /// <param name="outgoingMailServer">The incoming mail server.</param>
 /// <param name="outgoingMailServerPort">The incoming mail server port.</param>
 /// <param name="isOutgoingMailServerSsl">A value indicating whether the incoming mail server uses ssl.</param>
 /// <param name="outgoingMailServerRequiresAuthentication">A value indicating whether the outgoing mail server requires authentication.</param>
 /// <param name="isSendAndReceiveUserNameAndPasswordSame">true if send and receive user name and password are the same.</param>
 /// <param name="sendUserName">The send email user name.</param>
 /// <param name="sendPassword">The send email password.</param>
 /// <param name="useAnEmailSignature">true if an email signature should be used; otherwise, false.</param>
 /// <param name="emailSignature">The email signature.</param>
 /// <param name="downloadNewEmail">The download new email options.</param>
 /// <param name="downloadEmailsFrom">The download emails from.</param>
 /// <param name="keepEmailCopiesOnServer">true, if emails should be kept on the server after download.</param>
 /// <param name="contentToSyncEmail">true, if email content should be synced; otherwise, false.</param>
 public AccountSettingsData(string accountName, EmailService emailService, EmailServiceProvider emailServiceProvider, string displayName, string emailAddress, string userName, string password, string incomingMailServer, ushort incomingMailServerPort, bool isIncomingMailServerSsl, string outgoingMailServer, ushort outgoingMailServerPort, bool isOutgoingMailServerSsl, bool outgoingMailServerRequiresAuthentication, bool isSendAndReceiveUserNameAndPasswordSame, string sendUserName, string sendPassword, bool useAnEmailSignature, string emailSignature, DownloadNewEmailOptions downloadNewEmail, DownloadEmailsFromOptions downloadEmailsFrom, bool keepEmailCopiesOnServer, bool contentToSyncEmail)
     : base()
 {
     // Initialise local variables
     ImageSource             = string.Format("/Assets/{0}.png", emailServiceProvider.ToString());
     AccountName             = accountName;
     EmailService            = emailService;
     EmailServiceProvider    = emailServiceProvider;
     DisplayName             = displayName;
     EmailAddress            = emailAddress;
     UserName                = (string.IsNullOrEmpty(userName) ? emailAddress : userName);
     Password                = password;
     IncomingMailServer      = incomingMailServer;
     IncomingMailServerPort  = incomingMailServerPort;
     IsIncomingMailServerSsl = isIncomingMailServerSsl;
     OutgoingMailServer      = outgoingMailServer;
     OutgoingMailServerPort  = outgoingMailServerPort;
     IsOutgoingMailServerSsl = isOutgoingMailServerSsl;
     OutgoingMailServerRequiresAuthentication = outgoingMailServerRequiresAuthentication;
     IsSendAndReceiveUserNameAndPasswordSame  = isSendAndReceiveUserNameAndPasswordSame;
     if (IsSendAndReceiveUserNameAndPasswordSame)
     {
         SendUserName = UserName;
         SendPassword = Password;
     }
     else
     {
         SendUserName = sendUserName;
         SendPassword = sendPassword;
     }
     UseAnEmailSignature     = useAnEmailSignature;
     EmailSignature          = emailSignature;
     DownloadNewEmail        = downloadNewEmail;
     DownloadEmailsFrom      = downloadEmailsFrom;
     KeepEmailCopiesOnServer = keepEmailCopiesOnServer;
     ContentToSyncEmail      = contentToSyncEmail;
 }
Пример #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="provider"></param>
 public ImapClient(EmailServiceProvider provider)
     : this(provider, Default.UserName, Default.Password)
 {
 }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="provider"></param>
        public void SetProperty(EmailServiceProvider provider)
        {
            String serverName = "";

            switch (provider)
            {
                case EmailServiceProvider.Gmail: serverName = "imap.gmail.com"; break;
                case EmailServiceProvider.Outlook: serverName = "imap-mail.outlook.com"; break;
                case EmailServiceProvider.YahooMail: serverName = "imap.mail.yahoo.com"; break;
                case EmailServiceProvider.AolMail: serverName = "imap.aol.com"; break;
                case EmailServiceProvider.ZohoMail: serverName = "imap.zoho.com"; break;
                default: throw new InvalidOperationException();
            }
            this.ServerName = serverName;
            this.Port = 993;
            this.Ssl = true;
        }
Пример #13
0
        /// <summary>
        /// Gets the default account settings data for the specified email service provider and email service.
        /// </summary>
        /// <param name="emailServiceProvider">The email service provider.</param>
        /// <param name="emailService">The email service.</param>
        /// <param name="accountName">The account name.</param>
        /// <param name="emailAddress">The email service provider.</param>
        /// <param name="password">The email service.</param>
        /// <param name="keepEmailsOnServerAfterDownload">true, if emails should be kept on the email server after download; otherwise, false.</param>
        /// <returns>The default account settings data.</returns>
        public async static Task <AccountSettingsDataList> GetDefaultAccountSettingsData(EmailServiceProvider emailServiceProvider, EmailService emailService, string accountName, string emailAddress, string password, bool keepEmailsOnServerAfterDownload)
        {
            // Stores the account settings list
            AccountSettingsDataList accountSettingsList = new AccountSettingsDataList();

            // Make sure the email service provider is not known
            if (emailServiceProvider == EmailServiceProvider.Other)
            {
                if (emailAddress.Contains("@gmail."))
                {
                    emailServiceProvider = EmailServiceProvider.Gmail;
                    emailService         = EmailService.Imap;
                }
                else if (emailAddress.Contains("@outlook."))
                {
                    emailServiceProvider = EmailServiceProvider.Outlook;
                    emailService         = EmailService.Pop;
                }
                else if (emailAddress.Contains("@live.") || emailAddress.Contains("@hotmail."))
                {
                    emailServiceProvider = EmailServiceProvider.Hotmail;
                    emailService         = EmailService.Pop;
                }
                else if (emailAddress.Contains("@yahoo."))
                {
                    emailServiceProvider = EmailServiceProvider.Yahoo;
                    emailService         = EmailService.Imap;
                }
                else if (emailAddress.Contains("@aol."))
                {
                    emailServiceProvider = EmailServiceProvider.Aol;
                    emailService         = EmailService.Imap;
                }
                else if (emailAddress.Contains("@gmx."))
                {
                    emailServiceProvider = EmailServiceProvider.Gmx;
                    emailService         = EmailService.Imap;
                }
                else if (emailAddress.Contains("@zoho."))
                {
                    emailServiceProvider = EmailServiceProvider.Zoho;
                    emailService         = EmailService.Imap;
                }
            }

            // Get the display name
            string displayName = await GetDisplayName();

            // Determine which email service provider was supplied
            switch (emailServiceProvider)
            {
            // Default Gmail settings
            case EmailServiceProvider.Gmail:
                accountSettingsList.Add(
                    new AccountSettingsData
                    (
                        accountName,
                        emailService,
                        emailServiceProvider,
                        displayName,
                        emailAddress,
                        emailAddress,
                        password,
                        (emailService == EmailService.Pop ? "pop.gmail.com" : "imap.gmail.com"),
                        (ushort)(emailService == EmailService.Pop ? 995 : 993),
                        "smtp.gmail.com",
                        465,
                        keepEmailsOnServerAfterDownload
                    ));
                break;

            // Default Hotmail settings
            case EmailServiceProvider.Outlook:
            case EmailServiceProvider.Hotmail:
                if (emailService != EmailService.Pop)
                {
                    throw new Exception(string.Format("{0} is not supported on {1}", emailService, emailServiceProvider));
                }
                else
                {
                    accountSettingsList.Add(
                        new AccountSettingsData
                        (
                            accountName,
                            emailService,
                            emailServiceProvider,
                            displayName,
                            emailAddress,
                            emailAddress,
                            password,
                            "pop3.live.com",
                            995,
                            "smtp.live.com",
                            587,
                            keepEmailsOnServerAfterDownload
                        ));
                }
                break;

            // Default Yahoo settings
            case EmailServiceProvider.Yahoo:
                if (emailService != EmailService.Pop)
                {
                    throw new Exception(string.Format("{0} is not supported on {1}", emailService, emailServiceProvider));
                }
                else
                {
                    accountSettingsList.Add(
                        new AccountSettingsData
                        (
                            accountName,
                            emailService,
                            emailServiceProvider,
                            displayName,
                            emailAddress,
                            emailAddress,
                            password,
                            (emailService == EmailService.Pop ? "pop.mail.yahoo.com" : "imap.mail.yahoo.com"),
                            (ushort)(emailService == EmailService.Pop ? 995 : 993),
                            "smtp.yahoo.com",
                            465,
                            keepEmailsOnServerAfterDownload
                        ));
                }
                break;

            // Default Aol settings
            case EmailServiceProvider.Aol:
                accountSettingsList.Add(
                    new AccountSettingsData
                    (
                        accountName,
                        emailService,
                        emailServiceProvider,
                        displayName,
                        emailAddress,
                        emailAddress.Split('@')[0],
                        password,
                        (emailService == EmailService.Pop ? "pop.aol.com" : "imap.aol.com"),
                        (ushort)(emailService == EmailService.Pop ? 995 : 993),
                        "smtp.aol.com",
                        587,
                        keepEmailsOnServerAfterDownload
                    ));
                break;

            // Default Gmx settings
            case EmailServiceProvider.Gmx:
                accountSettingsList.Add(
                    new AccountSettingsData
                    (
                        accountName,
                        emailService,
                        emailServiceProvider,
                        displayName,
                        emailAddress,
                        emailAddress,
                        password,
                        (emailService == EmailService.Pop ? "pop.gmx.net" : "imap.gmx.net"),
                        (ushort)(emailService == EmailService.Pop ? 995 : 993),
                        "mail.gmx.net",
                        465,
                        keepEmailsOnServerAfterDownload
                    ));
                break;

            // Default Zoho settings
            case EmailServiceProvider.Zoho:
                accountSettingsList.Add(
                    new AccountSettingsData
                    (
                        accountName,
                        emailService,
                        emailServiceProvider,
                        displayName,
                        emailAddress,
                        emailAddress,
                        password,
                        (emailService == EmailService.Pop ? "pop.zoho.com" : "imap.zoho.com"),
                        (ushort)(emailService == EmailService.Pop ? 995 : 993),
                        "smtp.zoho.com",
                        465,
                        keepEmailsOnServerAfterDownload
                    ));
                break;

            // Default custom settings
            default:
                string domainName     = emailAddress.Split('@')[1];
                bool[] trueFalseFlags = { false, true };

                // Loop through each well known incoming email server protocol
                foreach (string wellKnownIncomingEmailServer in Enum.GetNames(typeof(WellKnownIncomingEmailServer)).Where(o => o.Contains(emailService.ToString()) ||
                                                                                                                          o.Contains(WellKnownIncomingEmailServer.Mail.ToString())))
                {
                    // Loop through each security
                    foreach (bool isIncomingMailServerSsl in trueFalseFlags)
                    {
                        // Get mail server ports for the current email protocol and security
                        IEnumerable <uint> incomingMailServerPorts = GetWellKnownIncomingEmailServerPorts((WellKnownIncomingEmailServer)Enum.Parse(typeof(WellKnownIncomingEmailServer), wellKnownIncomingEmailServer), isIncomingMailServerSsl, emailService);

                        // Loop through each incoming mail server port
                        foreach (ushort incomingMailServerPort in incomingMailServerPorts)
                        {
                            // Loop through each well known incoming email server protocol
                            foreach (string wellKnownOutgoingEmailServer in Enum.GetNames(typeof(WellKnownOutgoingEmailServer)).Union(new string[] { wellKnownIncomingEmailServer }))
                            {
                                // Loop through each security
                                foreach (bool isOutgoingMailServerSsl in trueFalseFlags)
                                {
                                    // Get mail server ports for the current email protocol and security
                                    IEnumerable <uint> outgoingMailServerPorts = GetWellKnownOutgoingEmailServerPorts(isOutgoingMailServerSsl);

                                    // Loop through each outgoing mail server port
                                    foreach (ushort outgoingMailServerPort in outgoingMailServerPorts)
                                    {
                                        // Loop through each user name
                                        foreach (string userName in new string[] { emailAddress, emailAddress.Split('@')[0] })
                                        {
                                            accountSettingsList.Add(
                                                new AccountSettingsData
                                                (
                                                    accountName.ToWords(),
                                                    emailService,
                                                    emailServiceProvider,
                                                    displayName,
                                                    emailAddress,
                                                    userName,
                                                    password,
                                                    string.Format("{0}.{1}", wellKnownIncomingEmailServer.ToLower(), domainName),
                                                    incomingMailServerPort,
                                                    isIncomingMailServerSsl,
                                                    string.Format("{0}.{1}", wellKnownOutgoingEmailServer.ToLower(), domainName),
                                                    outgoingMailServerPort,
                                                    isOutgoingMailServerSsl,
                                                    true,
                                                    true,
                                                    userName,
                                                    password,
                                                    true,
                                                    MailMessage.DefaultSignature,
                                                    DownloadNewEmailOptions.AsItemsArrive,
                                                    DownloadEmailsFromOptions.Anytime,
                                                    keepEmailsOnServerAfterDownload,
                                                    true
                                                ));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            }

            return(accountSettingsList);
        }
Пример #14
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Data.AccountSettingsData class.
 /// </summary>
 /// <param name="accountName">The account name.</param>
 /// <param name="emailService">The email service.</param>
 /// <param name="emailServiceProvider">The email service provider.</param>
 /// <param name="displayName">The email display name.</param>
 /// <param name="emailAddress">The email address.</param>
 /// <param name="userName">The user name.</param>
 /// <param name="password">The email password.</param>
 /// <param name="incomingMailServer">The incoming mail server.</param>
 /// <param name="incomingMailServerPort">The incoming mail server port.</param>
 /// <param name="isIncomingMailServerSsl">A value indicating whether the incoming mail server uses ssl.</param>
 /// <param name="outgoingMailServer">The incoming mail server.</param>
 /// <param name="outgoingMailServerPort">The incoming mail server port.</param>
 /// <param name="isOutgoingMailServerSsl">A value indicating whether the incoming mail server uses ssl.</param>
 /// <param name="outgoingMailServerRequiresAuthentication">A value indicating whether the outgoing mail server requires authentication.</param>
 /// <param name="isSendAndReceiveUserNameAndPasswordSame">true if send and receive user name and password are the same.</param>
 /// <param name="sendUserName">The send email user name.</param>
 /// <param name="sendPassword">The send email password.</param>
 /// <param name="keepEmailsOnServerAfterDownload">true, if emails should be kept on the server after download.</param>
 public AccountSettingsData(string accountName, EmailService emailService, EmailServiceProvider emailServiceProvider, string displayName, string emailAddress, string userName, string password, string incomingMailServer, ushort incomingMailServerPort, bool isIncomingMailServerSsl, string outgoingMailServer, ushort outgoingMailServerPort, bool isOutgoingMailServerSsl, bool outgoingMailServerRequiresAuthentication, bool isSendAndReceiveUserNameAndPasswordSame, string sendUserName, string sendPassword, bool keepEmailsOnServerAfterDownload)
     : this(accountName, emailService, emailServiceProvider, displayName, emailAddress, userName, password, incomingMailServer, incomingMailServerPort, isIncomingMailServerSsl, outgoingMailServer, outgoingMailServerPort, isOutgoingMailServerSsl, outgoingMailServerRequiresAuthentication, isSendAndReceiveUserNameAndPasswordSame, sendUserName, sendPassword, true, MailMessage.DefaultSignature, DownloadNewEmailOptions.AsItemsArrive, DownloadEmailsFromOptions.Anytime, keepEmailsOnServerAfterDownload, true)
 {
 }
Пример #15
0
 /// <summary>
 /// Initialises a new instance of the Skycap.Data.AccountSettingsData class.
 /// </summary>
 /// <param name="accountName">The account name.</param>
 /// <param name="emailService">The email service.</param>
 /// <param name="emailServiceProvider">The email service provider.</param>
 /// <param name="displayName">The email display name.</param>
 /// <param name="emailAddress">The email address.</param>
 /// <param name="userName">The email user name.</param>
 /// <param name="password">The email password.</param>
 /// <param name="incomingMailServer">The incoming mail server.</param>
 /// <param name="incomingMailServerPort">The incoming mail server port.</param>
 /// <param name="outgoingMailServer">The incoming mail server.</param>
 /// <param name="outgoingMailServerPort">The incoming mail server port.</param>
 /// <param name="keepEmailsOnServerAfterDownload">true, if emails should be kept on the server after download.</param>
 public AccountSettingsData(string accountName, EmailService emailService, EmailServiceProvider emailServiceProvider, string displayName, string emailAddress, string userName, string password, string incomingMailServer, ushort incomingMailServerPort, string outgoingMailServer, ushort outgoingMailServerPort, bool keepEmailsOnServerAfterDownload)
     : this(accountName, emailService, emailServiceProvider, displayName, emailAddress, userName, password, incomingMailServer, incomingMailServerPort, true, outgoingMailServer, outgoingMailServerPort, true, true, true, userName, password, true, MailMessage.DefaultSignature, DownloadNewEmailOptions.AsItemsArrive, DownloadEmailsFromOptions.Anytime, keepEmailsOnServerAfterDownload, true)
 {
 }
Пример #16
0
        /// <summary>
        /// Show popup on screen.
        /// </summary>
        public void Show()
        {
            // Dialog is open
            MainPage.Current.IsDialogOpen = true;

            // Hide show more or less hyperlink buttons by default
            hbShowMoreDetails.Visibility = Visibility.Collapsed;
            hbShowLessDetails.Visibility = Visibility.Collapsed;

            // Set default ports
            SetDefaultPorts(true, true);

            // Set title background
            SetTitleBackground();

            // Set sub title and incoming server
            txtSubTitle.Text           = string.Format("Complete the information below to connect to your {0} account", EmailServiceProvider.ToString());
            tbIncomingEmailServer.Text = string.Format("Incoming ({0}) email server", EmailService.ToString().ToUpper());

            // Set MailAccountDialog properties
            cdMailAccountDialog.Title            = string.Format("Add your {0} account", EmailServiceProvider.ToString());
            cdMailAccountDialog.TitleImageSource = new BitmapImage(new Uri(this.BaseUri, string.Format("/Assets/{0}.png", EmailServiceProvider.ToString())));
            cdMailAccountDialog.IsOpen           = true;
        }
Пример #17
0
        /// <summary>
        /// Determines if the supplied connection info is valid.
        /// </summary>
        /// <param name="message">The validation message.</param>
        /// <param name="isManualConfiguration">true if manual configuration; otherwise, false.</param>
        /// <param name="accountName">The account name.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="username">The user name.</param>
        /// <param name="password">The password.</param>
        /// <param name="incomingEmailServer">The incoming email server.</param>
        /// <param name="incomingEmailServerPort">The incoming email server port.</param>
        /// <param name="incomingEmailServerRequiresSsl">true, if the incoming email server requires ssl; otherwise, false.</param>
        /// <param name="outgoingEmailServer">The outgoing email server.</param>
        /// <param name="outgoingEmailServerPort">The outgoing email server port.</param>
        /// <param name="outgoingEmailServerRequiresSsl">true, if the outgoing email server requires ssl; otherwise, false.</param>
        /// <param name="outgoingMailServerRequiresAuthentication">true, if the outgoing email server requires authentication; otherwise false.</param>
        /// <param name="useTheSameUsernameAndPasswordToSendAndReceiveEmail">true, if the same username and password to send and receive email; otherwise false.</param>
        /// <param name="sendUsername">The smtp user name.</param>
        /// <param name="sendPassword">The smtp password.</param>
        /// <returns>true, if connection info is valid; otherwise, false.</returns>
        private bool IsConnectionInfoValid(out string message, out bool isManualConfiguration, out string accountName, out string displayName, out string emailAddress, out string username, out string password, out string incomingEmailServer, out ushort incomingEmailServerPort, out bool incomingEmailServerRequiresSsl, out string outgoingEmailServer, out ushort outgoingEmailServerPort, out bool outgoingEmailServerRequiresSsl, out bool outgoingMailServerRequiresAuthentication, out bool useTheSameUsernameAndPasswordToSendAndReceiveEmail, out string sendUsername, out string sendPassword)
        {
            // Default variables
            message = string.Empty;
            isManualConfiguration = (EmailServiceProvider == EmailServiceProvider.Other && hbShowMoreDetails.Visibility == Visibility.Collapsed);
            accountName           = string.Empty;
            displayName           = Task.Run(() => AccountSettingsData.GetDisplayName()).Result;
            emailAddress          = txtEmailAddress.Text.Trim();
            username                                           = txtUsername.Text.Trim();
            password                                           = pbPassword.Password.Trim();
            incomingEmailServer                                = txtIncomingEmailServer.Text.Trim();
            incomingEmailServerPort                            = ushort.Parse(txtIncomingEmailServerPort.Text.Trim());
            incomingEmailServerRequiresSsl                     = cbIncomingEmailServerRequiresSsl.IsChecked.Value;
            outgoingEmailServer                                = txtOutgoingEmailServer.Text.Trim();
            outgoingEmailServerPort                            = ushort.Parse(txtOutgoingEmailServerPort.Text.Trim());
            outgoingEmailServerRequiresSsl                     = cbOutgoingEmailServerRequiresSsl.IsChecked.Value;
            outgoingMailServerRequiresAuthentication           = cbOutgoingMailServerRequiresAuthentication.IsChecked.Value;
            useTheSameUsernameAndPasswordToSendAndReceiveEmail = cbUseTheSameUsernameAndPasswordToSendAndReceiveEmail.IsChecked.Value;
            sendUsername                                       = txtSendUsername.Text.Trim();
            sendPassword                                       = pbSendPassword.Password.Trim();

            // Validate email address
            if (string.IsNullOrEmpty(emailAddress) ||
                !Regex.IsMatch(emailAddress, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
            {
                txtEmailAddress.Focus(FocusState.Programmatic);
                message = "Please specify a valid email address.";
                return(false);
            }
            // Validate password
            else if (string.IsNullOrEmpty(password))
            {
                pbPassword.Focus(FocusState.Programmatic);
                message = "Please specify the password.";
                return(false);
            }
            // Else if manual configuration
            else if (EmailServiceProvider == EmailServiceProvider.Other)
            {
                if (hbShowLessDetails.Visibility == Visibility.Visible)
                {
                    // Validate incoming email server
                    if (string.IsNullOrEmpty(incomingEmailServer))
                    {
                        txtIncomingEmailServer.Focus(FocusState.Programmatic);
                        message = "Please specify the incoming email server.";
                        return(false);
                    }
                    // Validate incoming email server port
                    else if (incomingEmailServerPort == 0)
                    {
                        txtIncomingEmailServerPort.Focus(FocusState.Programmatic);
                        message = "Please specify the incoming email server port.";
                        return(false);
                    }
                    // Validate outgoing email server
                    else if (string.IsNullOrEmpty(outgoingEmailServer))
                    {
                        txtOutgoingEmailServer.Focus(FocusState.Programmatic);
                        message = "Please specify the outgoing email server.";
                        return(false);
                    }
                    // Validate outgoing email server port
                    else if (outgoingEmailServerPort == 0)
                    {
                        txtOutgoingEmailServerPort.Focus(FocusState.Programmatic);
                        message = "Please specify the outgoing email server port.";
                        return(false);
                    }
                    else if (!cbUseTheSameUsernameAndPasswordToSendAndReceiveEmail.IsChecked.Value)
                    {
                        // Validate smtp user name
                        if (string.IsNullOrEmpty(sendUsername))
                        {
                            txtSendUsername.Focus(FocusState.Programmatic);
                            message = "Please specify the outgoing email server user name.";
                            return(false);
                        }
                        // Validate smtp password
                        else if (string.IsNullOrEmpty(sendPassword))
                        {
                            pbSendPassword.Focus(FocusState.Programmatic);
                            message = "Please specify the outgoing email server password.";
                            return(false);
                        }
                    }
                }
            }

            // Set the account name
            if (EmailServiceProvider == EmailServiceProvider.Other)
            {
                string domainPart = emailAddress.Split('@')[1];
                accountName = domainPart.Split('.')[0].ToWords();
            }
            else
            {
                accountName = EmailServiceProvider.ToString();
            }

            // If we reach this point, all connection info is valid
            return(true);
        }
Пример #18
0
 public Task SendAsync(IdentityMessage message)
 {
     return(EmailServiceProvider.SendConfirmationEmail(message));
 }
Пример #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="provider"></param>
 public SmtpClient(EmailServiceProvider provider)
     : this(provider, Default.UserName, Default.Password)
 {
 }
Пример #20
0
 public void SetUp()
 {
     _emailSP     = new EmailServiceProvider();
     _emailSPcomb = new EmailServiceProvider(true);
 }
Пример #21
0
        public async Task <IHttpActionResult> Register(TournamentApplication application)
        {
            if (ModelState.IsValid)
            {
                Company         c    = _dbContext.Companies.Find(application.CompanyId);
                ApplicationUser user = GetAuthUser();
                if (application.Game == Game.StarCraft2)
                {
                    if (string.IsNullOrEmpty(application.BattleNetId))
                    {
                        return(BadRequest("Моля попълнете Battle.net battle tag!"));
                    }
                    if (_dbContext.TournamentApplications.Where(a => a.BattleNetId == application.BattleNetId && a.TournamentId == application.TournamentId).SingleOrDefault() != null)
                    {
                        return(BadRequest($"Вече има направена регистрация с battle tag {application.BattleNetId}!"));
                    }
                    if (user.BattleNetId == null || user.BattleNetId != application.BattleNetId)
                    {
                        _dbContext.Users.Find(user.Id).BattleNetId = application.BattleNetId;
                    }
                }
                else
                {
                    if (application.TeamId == Guid.Empty)
                    {
                        return(BadRequest("Моля попълнете отбор във формата за регистрация!"));
                    }
                    if (_dbContext.TournamentApplications.Where(a => a.TeamId == application.TeamId && a.TournamentId == application.TournamentId).SingleOrDefault() != null)
                    {
                        return(BadRequest("Вече има направена регистрация за този отбор!"));
                    }
                }
                if (c == null)
                {
                    _dbContext.Companies.Add(new Company()
                    {
                        Name = application.CompanyId
                    });
                }
                application.UniqueHash(_dbContext);
                application.UserId = user.Id;
                _dbContext.TournamentApplications.Add(application);

                try
                {
                    _dbContext.SaveChanges();
                }
                catch (DbUpdateException e)
                {
                    System.Diagnostics.Trace.TraceError("Tournament registration error: " + e.Message);
                    return(BadRequest("Нещо се обърка..."));
                }

                try
                {
                    string gameMsg = application.Game == Game.CSGO ? "Вашата регистрация е за участие в лигата по CS:GO" :
                                     $"Вашата регистрация е за участие в лигата по StarCraft II, с battle tag {application.BattleNetId}";
                    string message = $@"Здравей, { user.UserName },
                                    <p>Успешно получихме вашата регистрация за Esports Бизнес Лигата. В регистрацията сте посочили, че текущо работите в <b>{ application.CompanyId }</b>. {gameMsg}. Регистрация ще бъде потвърдена след като преведете таксата за участие (60лв. с ДДС за лигата по StarCraft II, или 300лв. с ДДС за лигата по CS:GO).</p>
                                    <p>Банковата ни сметка е</p>
                                    <ul>
                                        <li>Име на Банката: <b>{ AppInfo.Config.bank }</b></li>
                                        <li>Титуляр: <b>{ AppInfo.Config.bankAccountOwner }</b></li>
                                        <li>Сметка: <b>{ AppInfo.Config.bankAccount }</b></span></li>
                                        <li>BIC: <b>{ AppInfo.Config.bic }</b></li>
                                    </ul>
                                    <p>Моля при превода да сложите в основанието уникалния код, който сме генерирали за вашата регистрация: <b>{ application.Hash }</b>. Можете да намерите кода и през вашият профил на сайта ни.</p>
                                    <p>Ако ви е нужна фактура, моля да се свържете с нас на <a href='mailto:[email protected]'>[email protected]</a>!</p>
                                    <p>Заповядайте и в нашият <a href='https://discord.gg/bnTcpa9'>дискорд сървър</a>!</p>
                                    <p>Поздрави от екипа на Bellum Gens!</p>
                                    <a href='https://eb-league.com' target='_blank'>https://eb-league.com</a>";
                    await EmailServiceProvider.SendNotificationEmail(application.Email, "Регистрацията ви е получена", message).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.TraceError("Tournament registration error: " + e.Message);
                }
                return(Ok(application));
            }
            return(BadRequest("Не успяхме да вилидираме информацията..."));
        }
Пример #22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="provider"></param>
        public void SetProperty(EmailServiceProvider provider)
        {
            String serverName = "";
            Int32 port = Default.Port;
            SmtpEncryptedCommunication encryptedCommunication = SmtpEncryptedCommunication.None;

            switch (provider)
            {
                case EmailServiceProvider.Gmail: serverName = "smtp.gmail.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;
                case EmailServiceProvider.Outlook: serverName = "smtp-mail.outlook.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;
                case EmailServiceProvider.YahooMail: serverName = "smtp.mail.yahoo.com"; encryptedCommunication = SmtpEncryptedCommunication.Ssl; break;
                case EmailServiceProvider.AolMail: serverName = "smtp.aol.com"; encryptedCommunication = SmtpEncryptedCommunication.Tls; break;
                case EmailServiceProvider.ZohoMail: serverName = "smtp.zoho.com"; encryptedCommunication = SmtpEncryptedCommunication.Ssl; break;
                default: throw new InvalidOperationException();
            }
            this.ServerName = serverName;

            switch (encryptedCommunication)
            {
                case SmtpEncryptedCommunication.None: port = 25; break;
                case SmtpEncryptedCommunication.Ssl: port = 465; break;
                case SmtpEncryptedCommunication.Tls: port = 587; break;
                default: throw new InvalidOperationException();
            }
            this.Port = port;
            this.EncryptedCommunication = encryptedCommunication;
        }
Пример #23
0
        public static void SendCombinationStringToEmail(string combinationString, string emailAddress)
        {
            EmailServiceProvider ep = new EmailServiceProvider(true);

            ep.SendEmailWithCombinationString(combinationString, emailAddress);
        }
        /// <summary>
        /// Determines if the supplied connection info is valid.
        /// </summary>
        /// <param name="requiresReconnect">true, if requires reconnect; otherwise, false.</param>
        /// <param name="accountName">The account name.</param>
        /// <param name="displayName">The display name.</param>
        /// <param name="emailService">The email service.</param>
        /// <param name="emailServiceProvider">The email service provider.</param>
        /// <param name="emailAddress">The email address.</param>
        /// <param name="username">The user name.</param>
        /// <param name="password">The password.</param>
        /// <param name="incomingEmailServer">The incoming email server.</param>
        /// <param name="incomingEmailServerPort">The incoming email server port.</param>
        /// <param name="incomingEmailServerRequiresSsl">true, if the incoming email server requires ssl; otherwise, false.</param>
        /// <param name="outgoingEmailServer">The outgoing email server.</param>
        /// <param name="outgoingEmailServerPort">The outgoing email server port.</param>
        /// <param name="outgoingEmailServerRequiresSsl">true, if the outgoing email server requires ssl; otherwise, false.</param>
        /// <param name="outgoingMailServerRequiresAuthentication">true, if the outgoing email server requires authentication; otherwise false.</param>
        /// <param name="useTheSameUsernameAndPasswordToSendAndReceiveEmail">true, if the same username and password to send and receive email; otherwise false.</param>
        /// <param name="sendUsername">The smtp user name.</param>
        /// <param name="sendPassword">The smtp password.</param>
        /// <param name="useAnEmailSignature">true, if use an email signature; otherwise, false.</param>
        /// <param name="emailSignature">The email signature.</param>
        /// <param name="downloadNewEmail">The download new email options.</param>
        /// <param name="downloadEmailsFrom">The download emails from options.</param>
        /// <param name="keepEmailCopiesOnServer">true, if keep email copies on server.</param>
        /// <param name="contentToSyncEmail">true, if emails should be synced; otherwise, false.</param>
        /// <returns>true, if connection info is valid; otherwise, false.</returns>
        private bool IsConnectionInfoValid(out bool requiresReconnect, out string accountName, out string displayName, out EmailService emailService, out EmailServiceProvider emailServiceProvider, out string emailAddress, out string username, out string password, out string incomingEmailServer, out ushort incomingEmailServerPort, out bool incomingEmailServerRequiresSsl, out string outgoingEmailServer, out ushort outgoingEmailServerPort, out bool outgoingEmailServerRequiresSsl, out bool outgoingMailServerRequiresAuthentication, out bool useTheSameUsernameAndPasswordToSendAndReceiveEmail, out string sendUsername, out string sendPassword, out bool useAnEmailSignature, out string emailSignature, out DownloadNewEmailOptions downloadNewEmail, out DownloadEmailsFromOptions downloadEmailsFrom, out bool keepEmailCopiesOnServer, out bool contentToSyncEmail)
        {
            // Default variables
            requiresReconnect       = false;
            accountName             = txtAccountName.Text.Trim();
            displayName             = txtDisplayName.Text.Trim();
            emailService            = SelectedAccountSettingsData.EmailService;
            emailServiceProvider    = SelectedAccountSettingsData.EmailServiceProvider;
            emailAddress            = txtEmailAddress.Text.Trim();
            username                = txtUsername.Text.Trim();
            password                = pbPassword.Password.Trim();
            incomingEmailServer     = txtIncomingEmailServer.Text.Trim();
            incomingEmailServerPort = 0;
            ushort.TryParse(txtIncomingEmailServerPort.Text.Trim(), out incomingEmailServerPort);
            incomingEmailServerRequiresSsl = cbIncomingEmailServerRequiresSsl.IsChecked.Value;
            outgoingEmailServer            = txtOutgoingEmailServer.Text.Trim();
            outgoingEmailServerPort        = 0;
            ushort.TryParse(txtOutgoingEmailServerPort.Text.Trim(), out outgoingEmailServerPort);
            outgoingEmailServerRequiresSsl                     = cbOutgoingEmailServerRequiresSsl.IsChecked.Value;
            outgoingMailServerRequiresAuthentication           = cbOutgoingMailServerRequiresAuthentication.IsChecked.Value;
            useTheSameUsernameAndPasswordToSendAndReceiveEmail = cbUseTheSameUsernameAndPasswordToSendAndReceiveEmail.IsChecked.Value;
            sendUsername        = txtSendUsername.Text.Trim();
            sendPassword        = pbSendPassword.Password.Trim();
            useAnEmailSignature = tsUseAnEmailSignature.IsOn;
            tbEmailSignature.Document.GetText(TextGetOptions.FormatRtf, out emailSignature);
            downloadNewEmail        = (DownloadNewEmailOptions)Enum.Parse(typeof(DownloadNewEmailOptions), (string)cbDownloadNewEmail.SelectedValue, true);
            downloadEmailsFrom      = (DownloadEmailsFromOptions)Enum.Parse(typeof(DownloadEmailsFromOptions), (string)cbDownloadEmailsFrom.SelectedValue, true);
            keepEmailCopiesOnServer = cbKeepEmailCopiesOnServer.IsChecked.Value;
            contentToSyncEmail      = cbContentToSyncEmail.IsChecked.Value;

            // If any connection info has changed
            if (!username.Equals(SelectedAccountSettingsData.UserName, StringComparison.OrdinalIgnoreCase) ||
                !password.Equals(SelectedAccountSettingsData.Password, StringComparison.OrdinalIgnoreCase) ||
                !incomingEmailServer.Equals(SelectedAccountSettingsData.IncomingMailServer, StringComparison.OrdinalIgnoreCase) ||
                incomingEmailServerPort != SelectedAccountSettingsData.IncomingMailServerPort ||
                incomingEmailServerRequiresSsl != SelectedAccountSettingsData.IsIncomingMailServerSsl ||
                !outgoingEmailServer.Equals(SelectedAccountSettingsData.OutgoingMailServer, StringComparison.OrdinalIgnoreCase) ||
                outgoingEmailServerPort != SelectedAccountSettingsData.OutgoingMailServerPort ||
                outgoingEmailServerRequiresSsl != SelectedAccountSettingsData.IsOutgoingMailServerSsl ||
                outgoingMailServerRequiresAuthentication != SelectedAccountSettingsData.OutgoingMailServerRequiresAuthentication ||
                useTheSameUsernameAndPasswordToSendAndReceiveEmail != SelectedAccountSettingsData.IsSendAndReceiveUserNameAndPasswordSame ||
                !sendUsername.Equals(SelectedAccountSettingsData.SendUserName, StringComparison.OrdinalIgnoreCase) ||
                !sendPassword.Equals(SelectedAccountSettingsData.SendPassword, StringComparison.OrdinalIgnoreCase))
            {
                requiresReconnect = true;
            }

            // Validate email address
            if (string.IsNullOrEmpty(emailAddress) ||
                !Regex.IsMatch(emailAddress, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
            {
                txtEmailAddress.Focus(FocusState.Programmatic);
                return(false);
            }
            // Validate password
            else if (string.IsNullOrEmpty(password))
            {
                pbPassword.Focus(FocusState.Programmatic);
                return(false);
            }
            // Validate incoming email server
            else if (string.IsNullOrEmpty(incomingEmailServer))
            {
                txtIncomingEmailServer.Focus(FocusState.Programmatic);
                return(false);
            }
            // Validate incoming email server port
            else if (incomingEmailServerPort == 0)
            {
                txtIncomingEmailServerPort.Focus(FocusState.Programmatic);
                return(false);
            }
            // Validate outgoing email server
            else if (string.IsNullOrEmpty(outgoingEmailServer))
            {
                txtOutgoingEmailServer.Focus(FocusState.Programmatic);
                return(false);
            }
            // Validate outgoing email server port
            else if (outgoingEmailServerPort == 0)
            {
                txtOutgoingEmailServerPort.Focus(FocusState.Programmatic);
                return(false);
            }
            else if (!cbUseTheSameUsernameAndPasswordToSendAndReceiveEmail.IsChecked.Value)
            {
                // Validate smtp user name
                if (string.IsNullOrEmpty(sendUsername))
                {
                    txtSendUsername.Focus(FocusState.Programmatic);
                    return(false);
                }
                // Validate smtp password
                else if (string.IsNullOrEmpty(sendPassword))
                {
                    pbSendPassword.Focus(FocusState.Programmatic);
                    return(false);
                }
            }

            // If we reach this point, all connection info is valid
            return(true);
        }
Пример #25
0
        /// <summary>
        /// Converts a value.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="language">The culture to use in the converter.</param>
        /// <returns>A converted value. If the method returns null, the valid null value is used.</returns>
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            EmailServiceProvider emailServiceProvider = (EmailServiceProvider)value;

            return(emailServiceProvider.ToString());
        }