Exemplo n.º 1
0
		private static int ProcessQueue()
		{
			var intQueueCount = 0;
			try
			{
				var dr = DataProvider.Instance().Queue_List();
				while (dr.Read())
				{
					intQueueCount += 1;
					var objEmail = new Message
					                   {
					                       Subject = dr["EmailSubject"].ToString(),
					                       SendFrom = dr["EmailFrom"].ToString(),
					                       SendTo = dr["EmailTo"].ToString(),
					                       Body = dr["EmailBody"].ToString(),
					                       BodyText = dr["EmailBodyPlainText"].ToString(),
					                   };

				    var canDelete = objEmail.SendMail();
					if (canDelete)
					{
						try
						{
							DataProvider.Instance().Queue_Delete(Convert.ToInt32(dr["Id"]));
						}
						catch (Exception ex)
						{
							Services.Exceptions.Exceptions.LogException(ex);
						}
					}
					else
					{
						intQueueCount = intQueueCount - 1;
					}
				}
				dr.Close();
				dr.Dispose();

				return intQueueCount;
			}
			catch (Exception ex)
			{
				Services.Exceptions.Exceptions.LogException(ex);
				return -1;
			}

		}
Exemplo n.º 2
0
        private int ProcessQueue()
        {
            int intQueueCount = 0;
            try
            {
                //Get Host SMTP Settings
                Hashtable objHost = Entities.Portals.PortalSettings.GetHostSettings();
                //Get Queue

                IDataReader dr = DataProvider.Instance().Queue_List();
                while (dr.Read())
                {
                    intQueueCount += 1;
                    var objEmail = new Message
                                       {
                                           Subject = dr["EmailSubject"].ToString(),
                                           SendFrom = dr["EmailFrom"].ToString(),
                                           SendTo = dr["EmailTo"].ToString(),
                                           Body = dr["EmailBody"].ToString(),
                                           BodyText = dr["EmailBodyPlainText"].ToString(),
                                           SmtpServer = Host.SMTPServer, // objHost["SMTPServer"].ToString(),
                                           SmtpUserName = Host.SMTPUsername, // objHost["SMTPUsername"].ToString(),
                                           SmtpPassword = Host.SMTPPassword, // objHost["SMTPPassword"].ToString(),
                                           SmtpAuthentication = Host.SMTPAuthentication, // objHost["SMTPAuthentication"].ToString(),
                                           SmtpSSL = Host.EnableSMTPSSL.ToString() // objHost["SMTPEnableSSL"].ToString()
                                       };

                    bool canDelete = objEmail.SendMail();
                    if (canDelete)
                    {
                        try
                        {
                            DataProvider.Instance().Queue_Delete(Convert.ToInt32(dr["Id"]));
                        }
                        catch (Exception ex)
                        {
                            Services.Exceptions.Exceptions.LogException(ex);
                        }
                    }
                    else
                    {
                        intQueueCount = intQueueCount - 1;
                    }
                }
                dr.Close();
                dr.Dispose();

                return intQueueCount;
            }
            catch (Exception ex)
            {
                Services.Exceptions.Exceptions.LogException(ex);
                return -1;
            }
        }