public static Object testEmail() { AlertMessenger aMsgr = new AlertMessenger(); object rObj = null; aMsgr._emailAddressesTO.Add("*****@*****.**"); aMsgr._emailAddressesTO.Add("*****@*****.**"); aMsgr._from = truckReservationEmail; aMsgr._subject = "TEST EMAIL"; aMsgr._body = "This is a truck appliction test for sending email."; try { rObj = aMsgr.sendAlertMessage(); } catch (Exception ex) { string strErr = " Exception Error in alertProcessing testEmail(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } return(rObj); }
public void createAndSendAlertSMS(int alertID, string additionalMsg) { DataSet dataSet = new DataSet(); aMsgr = new AlertMessenger(); try { using (var scope = new TransactionScope()) { sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.StoredProcedure, "sp_truckschedapp_getSMSSubscribersForAlertwAll", new SqlParameter("@pAlertID", alertID)); List <string> SentList = new List <string>(); bool canSendAlert = true; //populate return object foreach (System.Data.DataRow row in dataSet.Tables[0].Rows) { canSendAlert = true; if (SentList.Contains(Convert.ToString(row["SMSemail"]))) { canSendAlert = false; } if (canSendAlert == true) { aMsgr._emailAddressesTO.Add(Convert.ToString(row["SMSemail"])); aMsgr._from = TSConfigHelper.truckReservationEmail; aMsgr._subject = Convert.ToString(row["SMSMessageSubject"]); aMsgr._body = "Default Message: " + Convert.ToString(row["SMSMessageBody"]); aMsgr._body = (additionalMsg != string.Empty) ? ("Additional Message: " + additionalMsg + aMsgr._body) : aMsgr._body; aMsgr.sendAlertMessage(); SentList.Add(Convert.ToString(row["SMSemail"])); aMsgr._emailAddressesTO.Clear(); } } scope.Complete(); } } catch (SqlException excep) { string strErr = " SQLException Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); throw excep; } catch (Exception ex) { string strErr = " Exception Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } finally { } }