Пример #1
0
        public EmailDetails GetEmailDetails(string AppCode, int PersID, MySqlConnection conn, string ContractNumber, string ContractName, string ContractEndDate, string DaysUntilExpired, string ToEmails, string CCEmails)
        {
            try
            {
                using (conn)
                {
                    //Open connection if not open
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    using (cmd)
                    {
                        cmd.Connection = conn;

                        cmd.Parameters.Clear();

                        cmd.Parameters.AddWithValue("AppCode", AppCode);
                        cmd.Parameters.AddWithValue("PersonID", PersID);
                        cmd.Parameters.AddWithValue("ContractNumber", ContractNumber);
                        cmd.Parameters.AddWithValue("ContractName", ContractName);
                        cmd.Parameters.AddWithValue("ContractEndDate", ContractEndDate);
                        cmd.Parameters.AddWithValue("DaysUntilExpired", DaysUntilExpired);
                        cmd.Parameters.AddWithValue("ToEmails", ToEmails);
                        cmd.Parameters.AddWithValue("CCEmails", CCEmails);

                        cmd.CommandText = "HSPD12Email_Main";
                        cmd.CommandType = CommandType.StoredProcedure;

                        MySqlDataReader emailData = cmd.ExecuteReader();

                        //Return details depending on type
                        while (emailData.Read())
                        {
                            return(EmailDetails.GetEmailDetails(emailData));
                        }

                        return(null);
                    }
                }
            }
            catch (MySqlException)
            {
                //Log exception
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// New method that access the DB and gets the email details.
        /// Developed as part of email consolidation.
        /// <summary>
        /// <param name="AppCode"></param>
        private void HSPD12Email(string AppCode, string ContractNumber, string ContractName, string ContractEndDate, string DaysUntilExpired, string ToEmails, string CCEmails)
        {
            //Declare function variables
            EmailDetails emailData = new EmailDetails();

            emailData = emailData.GetEmailDetails(AppCode, personID, conn, ContractNumber, ContractName, ContractEndDate, DaysUntilExpired, ToEmails, CCEmails);
            if (emailData != null)
            {
                string strEmailAttachment = string.Empty;
                if (emailData.EmailAttachment.IndexOf(";") > 0)
                {
                    strEmailAttachment = onboardingLocation + emailData.EmailAttachment.Replace(";", string.Concat(";", onboardingLocation));
                }

                if (emailData.EmailFromAdd.Contains("@"))
                {
                    message.Send(emailData.EmailFromAdd, emailData.EmailToAdd, emailData.EmailCCAdd, emailData.EmailBCCAdd, emailData.EmailSubject, emailData.EmailBody, strEmailAttachment, smtpServer, true);
                }
            }
        }