public static ArrayList Send(int IncidentId, EMailRouterPop3Box pop3Box, Pop3Message InMsg, string[] RecipientEmails) { ArrayList retVal = new ArrayList(); IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IncidentId)); EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock; if (pop3Box.IsInternal) { #region Internal -> Extrenal // Internal -> Internal Info // 2009-06-16 OZ: Add Chech send emails to internal users if (settings.AllowEMailRouting) { // 2007-02-12 OZ: "FN LN" <*****@*****.**> string FromEmail = string.Format("\"{0} {1}\" <{2}>", Security.CurrentUser.LastName, Security.CurrentUser.FirstName, pop3Box.EMailAddress); OutputMessageCreator output2Iternal = new OutputMessageCreator(InMsg, IncidentId, pop3Box.EMailAddress, FromEmail); // Exclude a message sender //output2Iternal.AddIgnoreRecipient(EMailMessage.GetSenderEmail(InMsg)); // Load InternalUser foreach (int UserId in GetInternalUsersByIncidentId(IncidentId)) { output2Iternal.AddRecipient(UserId); retVal.Add(UserId); } // Load InformationRecipientList // foreach(int infoRecipient in IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock.InformationRecipientList) // { // output2Iternal.AddRecipient(infoRecipient); // } foreach (OutputMessage outputMsg in output2Iternal.Create()) { //try //{ SmtpClientUtility.SendMessage(OutgoingEmailServiceType.HelpDeskEmailBox, pop3Box.EMailRouterPop3BoxId, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data); //} //catch(Exception ex) //{ // System.Diagnostics.Trace.WriteLine(ex); // Log.WriteError(ex.ToString()); //} } } // Internal -> Extrenal string publicEmail = FindEMailRouterPublicEmail(IncidentId); if (publicEmail != string.Empty) { //EMailRouterPop3Box externalPop3Box = EMailRouterPop3Box.Load(realEMailBoxId); OutputMessageCreator output2External = new OutputMessageCreator(InMsg, IncidentId, publicEmail, publicEmail); // Load External Senders // foreach(string exRecipient in EMailMessage.GetExternalSendersByIncidentId(IncidentId)) // { // output2External.AddRecipient(exRecipient); // } // Load External Senders foreach (EMailIssueExternalRecipient exRecipient in EMailIssueExternalRecipient.List(IncidentId)) { output2External.AddRecipient(exRecipient.EMail); } // 2007-03-12 RecipientEmails Addon if (RecipientEmails != null) { foreach (string exItem in RecipientEmails) { int emailUserId = DBUser.GetUserByEmail(exItem, false); if (emailUserId > 0) { if (!retVal.Contains(emailUserId)) { output2External.AddRecipient(exItem); retVal.Add(emailUserId); } } else { output2External.AddRecipient(exItem); } } } // int emailBoxId = EMail.EMailRouterOutputMessage.FindEMailRouterPublicId(IncidentId); foreach (OutputMessage outputMsg in output2External.Create()) { //try //{ SmtpClientUtility.SendMessage(OutgoingEmailServiceType.HelpDeskEmailBox, emailBoxId, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data); //} //catch(Exception ex) //{ // System.Diagnostics.Trace.WriteLine(ex); // Log.WriteError(ex.ToString()); //} } } #endregion } else { if (!settings.AllowEMailRouting) { return(retVal); } EMailRouterPop3Box internalPop3Box = EMailRouterPop3Box.ListInternal(); if (internalPop3Box == null) { return(retVal); } #region // External -> Internal // External -> Internal string SenderName = EMailMessage.GetSenderName(InMsg); string FromEmail = SenderName == string.Empty?internalPop3Box.EMailAddress: string.Format("\"{0}\" <{1}>", SenderName, internalPop3Box.EMailAddress); OutputMessageCreator output = new OutputMessageCreator(InMsg, IncidentId, internalPop3Box.EMailAddress, FromEmail); string Subject = (InMsg.Subject == null?string.Empty:InMsg.Subject); if (Subject == string.Empty) { // OZ: Maybe: Set Default Inicdent Title if subject is empty //Subject = Incident.GetIncidentTitle(IncidentId); } if (TicketUidUtil.LoadFromString(Subject) == string.Empty) { output.Subject = string.Format("[{0}] {1}", TicketUidUtil.Create(incidentBox.IdentifierMask, IncidentId), Subject); } foreach (int UserId in GetInternalUsersByIncidentId(IncidentId)) { output.AddRecipient(UserId); retVal.Add(UserId); } // IncidentBoxDocument incidentDoc = IncidentBoxDocument.Load(incidentBox.IncidentBoxId); // // foreach(int infoRecipient in incidentDoc.EMailRouterBlock.InformationRecipientList) // { // output.AddRecipient(infoRecipient); // } foreach (OutputMessage outputMsg in output.Create()) { //try //{ SmtpClientUtility.SendMessage(OutgoingEmailServiceType.HelpDeskEmailBox, internalPop3Box.EMailRouterPop3BoxId, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data); //} //catch(Exception ex) //{ // System.Diagnostics.Trace.WriteLine(ex); // Log.WriteError(ex.ToString()); //} } #endregion } return(retVal); }
private void BindReipients(EMailRouterIncidentBoxBlock eribb) { lblRecipients.Text = ""; lblChangeButton2.Text = ""; string sResps = ""; string sUsers = ""; DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("PureName", typeof(string))); dt.Columns.Add(new DataColumn("UserName", typeof(string))); DataRow dr; if (eribb.InformationRecipientList != null) foreach (int iUserId in eribb.InformationRecipientList) { sUsers += iUserId + "_"; dr = dt.NewRow(); dr["PureName"] = Util.CommonHelper.GetUserStatusPureName(iUserId); dr["UserName"] = Util.CommonHelper.GetUserStatus(iUserId); dt.Rows.Add(dr); } DataView dv = dt.DefaultView; dv.Sort = "PureName"; foreach (DataRowView drv in dv) sResps += drv["UserName"].ToString() + "<br />"; if (sResps.Length == 0) sResps = " "; lblRecipients.Text = String.Format("<span class='text' style='width:180px;'>{0}</span> ", sResps); CommandManager cm = CommandManager.GetCurrent(this.Page); CommandParameters cp = new CommandParameters("MC_HDM_AdminResponsiblePool2"); cp.CommandArguments = new System.Collections.Generic.Dictionary<string, string>(); cp.AddCommandArgument("sUsersKey", sUsers); string cmd = cm.AddCommand("Incident", "", "IncidentView", cp); cmd = cmd.Replace("\"", """); lblChangeButton2.Text = String.Format("<a href=\"javascript:{{{2}}}\"><img align='absmiddle' border='0' src='{0}' /> {1}</a>", this.Page.ResolveUrl("~/layouts/images/icons/regular.gif"), LocRM.GetString("tChange"), cmd); }