Example #1
0
 /// <summary>
 /// Sending Email with the newly created CSV attached
 /// </summary>
 /// <param></param>
 /// <returns></returns>
 private void SendEmail()
 {
     try
     {
         List <string> mailCC      = new List <string>();
         List <string> attachement = new List <string>();
         StringBuilder bodyBuilder = new StringBuilder();
         string        body        = String.Empty;
         string        title       = String.Format("MUTUAL FUND {0}", DateTime.Now.ToString("dd/MM/yy"));
         bodyBuilder.Append("<p>");
         foreach (string signatureLine in configObj.MailSignature)
         {
             bodyBuilder.AppendFormat("{0}<br />", signatureLine);
         }
         bodyBuilder.Append("</p>");
         body = bodyBuilder.ToString();
         attachement.Add(String.Format("{0}Results_{1}.xls", configObj.ResultFilePath, resultFileName));
         if (configObj.MailCC.Count > 1 || (configObj.MailCC.Count == 1 && configObj.MailCC[0] != ""))
         {
             mailCC = configObj.MailCC;
         }
         EWSUtility.CreateAndSendMail(service, configObj.MailTo, mailCC, new List <string>(), title, body, attachement);
     }
     catch (Exception ex)
     {
         string msg = "Cannot send mail :" + ex;
         Logger.Log(msg, Logger.LogType.Error);
     }
 }
Example #2
0
 /// <summary>
 /// Sending Email with the newly created CSV attached
 /// </summary>
 /// <param></param>
 /// <returns></returns>
 private void SendEmail()
 {
     try
     {
         var    mailCC      = new List <string>();
         var    attachement = new List <string>();
         string body        = String.Empty;
         string title       = String.Empty;
         if (updatedCountries.Count == 0)
         {
             title = "No New Pre-IPO Records Today";
         }
         else
         {
             var bodyBuilder = new StringBuilder();
             title = "New Pre-IPO Records";
             bodyBuilder.Append("Please find the new Pre-IPO records for ");
             for (int count = 0; count < updatedCountries.Count; count++)
             {
                 bodyBuilder.Append(updatedCountries[count]);
                 if (updatedCountries.Count >= 2 && count == updatedCountries.Count - 2)
                 {
                     bodyBuilder.Append(" & ");
                 }
                 else if (count != updatedCountries.Count - 1)
                 {
                     bodyBuilder.Append(", ");
                 }
                 else
                 {
                     bodyBuilder.Append(".");
                 }
             }
             bodyBuilder.Append("<p>");
             foreach (string signatureLine in _configObj.MailSignature)
             {
                 bodyBuilder.AppendFormat("{0}<br />", signatureLine);
             }
             bodyBuilder.Append("</p>");
             body = bodyBuilder.ToString();
             attachement.Add(_resultFilename);
         }
         if (_configObj.MailCC.Count > 1 || (_configObj.MailCC.Count == 1 && _configObj.MailCC[0] != ""))
         {
             mailCC = _configObj.MailCC;
         }
         EWSUtility.CreateAndSendMail(_service, _configObj.MailTo, mailCC, new List <string>(), title, body, attachement);
     }
     catch (Exception ex)
     {
         string msg = "Cannot send mail :" + ex;
         LogMessage(msg, Logger.LogType.Error);
     }
 }
Example #3
0
        /// <summary>
        /// SendMail
        /// </summary>
        /// <param name="service">Login Email</param>
        /// <param name="subject">subject</param>
        /// <param name="content">Body</param>
        /// <param name="attacheFileList">Attachements</param>
        private void SendMail(ExchangeService service, string subject, string content, List <string> attacheFileList)
        {
            StringBuilder bodyBuilder = new StringBuilder();

            bodyBuilder.Append(content);
            bodyBuilder.Append("<p>");
            foreach (string signatureLine in configObj.MailSignature)
            {
                bodyBuilder.AppendFormat("{0}<br />", signatureLine);
            }
            bodyBuilder.Append("</p>");
            content = bodyBuilder.ToString();
            if (configObj.MailCC.Count > 1 || (configObj.MailCC.Count == 1 && configObj.MailCC[0] != ""))
            {
                listMailCC = configObj.MailCC;
            }
            EWSUtility.CreateAndSendMail(service, listMailTo, listMailCC, new List <string>(), subject, content, attacheFileList);
        }
        /// <summary>
        /// SendMail
        /// </summary>
        /// <param name="service">Login Email</param>
        /// <param name="subject">subject</param>
        /// <param name="content">Body</param>
        /// <param name="attacheFileList">Attachements</param>
        private void SendMail(string subject, string content, List <string> attacheFileList)
        {
            StringBuilder bodyBuilder = new StringBuilder();

            bodyBuilder.Append(content);
            bodyBuilder.Append("<p>");
            foreach (string signatureLine in configObj.MailSignature)
            {
                bodyBuilder.AppendFormat("{0}<br />", signatureLine);
            }
            bodyBuilder.Append("</p>");
            content = bodyBuilder.ToString();
            service = EWSUtility.CreateService(new System.Net.NetworkCredential(accountName, password, domain), new Uri(@"https://apac.mail.erf.thomson.com/EWS/Exchange.asmx"));
            if (configObj.MailCC.Count > 1 || (configObj.MailCC.Count == 1 && configObj.MailCC[0] != ""))
            {
                listMailCC = configObj.MailCC;
            }
            EWSUtility.CreateAndSendMail(service, listMailTo, listMailCC, new List <string>(), subject, content, attacheFileList);
        }