void GenAlertMessages(FRAME frame) { m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.WatchList.WatchList_NumAlerts].Accumulator.Increment(1); m_AppData.HealthStatistics[(int)APPLICATION_DATA.HEALTH_STATISTICS.WatchList.WatchList_LastAlert].StatString.SetValue = (string)frame.WatchListMatchingNumber; if (((WatchListControl)frame.ParentWatchList).WatchEmailAddresses == null) { return; } foreach (string to in ((WatchListControl)frame.ParentWatchList).WatchEmailAddresses) { EmailServices.SEND_MESSAGE message = new EmailServices.SEND_MESSAGE(); message.to = to; string attachement = m_DVR.Paths.GetCompleteFilePath(frame.JpegFileRelativePath); /// the email server has a problem that if you attach a file to a new mail, and then /// send multiple emails with the same attachment, you get an exception of file open by another process. /// so create a new file copy for each mail that is sent. Don't keep this file around forever. /// message.attachment = m_DVR.GetUniqueCopy(attachement); message.from = m_EmailService.FromAddress; message.subject = "ALERT: " + frame.WatchListMatchingNumber + " Sent at " + DateTime.UtcNow.ToString(); message.body = message.subject + Environment.NewLine + Environment.NewLine + "From PSS: " + frame.PSSName + Environment.NewLine + Environment.NewLine + "Camera Source: " + frame.SourceName + Environment.NewLine + Environment.NewLine + "Hot list entry: " + frame.WatchListMatchingNumber + ", " + frame.WatchListMatchingNumberUserComment + Environment.NewLine + Environment.NewLine + "Detected Nunmber: " + frame.BestMatchingString + Environment.NewLine + Environment.NewLine + "Match Probability: " + frame.MatchScore.ToString() + "%" + Environment.NewLine + Environment.NewLine + "Jpeg Image: " + frame.JpegFileRelativePath + Environment.NewLine + Environment.NewLine + "GPS Location: " + frame.GPSPosition + Environment.NewLine + Environment.NewLine + "Plot location URL: " + mapURL + frame.GPSPosition + Environment.NewLine + Environment.NewLine + "Observation time: " + frame.TimeStamp.ToString(); message.sendResultCallBack = OnSendMessageSendStatus; m_EmailService.SendMessage(message); m_Log.Log("WL sent message : " + message.subject, ErrorLog.LOG_TYPE.INFORMATIONAL); } }
private void buttonSendTestEmail_Click(object sender, EventArgs e) { if (!RecoverUserInput()) { return; } EmailServices.SEND_MESSAGE message = new EmailServices.SEND_MESSAGE(); m_EmailServices.EmaiSettings.LoadSettings();// re-load internal config settings that have just been modified and saved to disk message.to = m_EmailServices.EmaiSettings.AdminAddress; message.from = m_EmailServices.EmaiSettings.FromAddress; message.subject = "Test message, sent at " + DateTime.UtcNow.ToString(); message.body = message.subject + " from System " + m_AppData.ThisComputerName;; message.sendResultCallBack = HandleSendTestResult; m_EmailServices.SendMessage(message); textBoxTestEmailStatus.Text = "Sent Message....waiting on result"; }