示例#1
0
        /// <summary>
        /// publish Small Scale email,, mail quantity <50,000
        /// </summary>
        /// <param name="dialogueSetting">Dialogue setting, such as database Id, workspaceId</param>
        /// <param name="contactGroup">Contact Group information</param>
        /// <param name="contacts">Contact Information</param>
        /// <param name="directEmail">parameters related with direct email, such as subject, fromaddress</param>
        /// <returns></returns>
        public String publishingSmallScaleEmail(DialogueSetting dialogueSetting, ContactGroup contactGroup, ContactFileInfo importFiles, DirectEmail directEmail)
        {

            logger.Debug(System.Environment.NewLine+"Begin sending Small Scale Email.");
            String result = "OK";
            try
            {
                String contactDatabaseId = dialogueSetting.contactDatabaseId;
                String workspaceId = dialogueSetting.workspaceId;
                String emailTypeId = dialogueSetting.emailTypeId;
                //String directEmailId = dialogueSetting.directEmailId;

                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);
                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, contactGroup.groupLabel, contactGroup.groupName);

                String importId = this.importContact(contactDatabaseId, contactGroupId, directEmail.reportReceiveAddress, importFiles);              

                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(emailTypeId, directEmail.emailLabel, directEmail.emailName, directEmail.subject, directEmail.description, directEmail.fromName, directEmail.fromAddress, directEmail.htmlContent);


                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);
                result = publishId;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
                // return ex.Message;

            }
            logger.Debug("Finish sending Small Scale Email. Publish Id is " + result);
            return result;
        }
示例#2
0
        /// <summary>
        /// publish Small Scale email, mail quantity >=50,000
        /// </summary>
        /// <param name="dialogueSetting">Dialogue setting, such as database Id, workspaceId</param>
        /// <param name="contactGroup">Contact Group information</param>
        /// <param name="contacts">Contact Information</param>
        /// <param name="directEmail">parameters related with direct email, such as subject, fromaddress</param>
        /// <returns></returns>
        public String publishingBulkEmail(DialogueSetting dialogueSetting, ContactGroup contactGroup, String fileName, DirectEmail directEmail)
        {

            logger.Debug(System.Environment.NewLine+"Begin sending Bulk Scale Email.");
            String result = "OK";
            try
            {
                String contactDatabaseId = dialogueSetting.contactDatabaseId;
                String workspaceId = dialogueSetting.workspaceId;
                String emailTypeId = dialogueSetting.emailTypeId;
              //  String directEmailId = "";

                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);
                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, contactGroup.groupLabel, contactGroup.groupName);

                DateTime scheduleAt = DateTime.Now;
                ImportContactAction importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                String importId = importContactAction.importContactFromFTP(contactDatabaseId, contactGroupId, fileName, directEmail.reportReceiveAddress, dialogueSetting.ftpAccountId, scheduleAt);
                Thread.Sleep(5 * 1000);
                while (true)
                {
                    importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                    importStatus status = importContactAction.getImportStatus(importId);

                    if (status.Equals(importStatus.ENDED))
                    {
                        logger.InfoFormat("import contact File " + fileName + " successfully");
                        break;
                    }
                    if (status.Equals(importStatus.STOPPED) || status.Equals(importStatus.ABORTED))
                    {
                        logger.InfoFormat("fail to import contact File " + fileName  + " as import status is " + status.ToString());
                        // throw new Exception("fail to import contact File " + fileName + " for transid " + transId + " as import status is " + status.ToString());
                        return "";
                        //break;
                    }
                    logger.InfoFormat("Checking the import status, and current import status is " + status.ToString() );
                    Thread.Sleep(60 * 1000);
                }
                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(emailTypeId, directEmail.emailLabel, directEmail.emailName, directEmail.subject, directEmail.description, directEmail.fromName, directEmail.fromAddress, directEmail.htmlContent);


                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);
                result = publishId;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
                // return ex.Message;

            }
            logger.Debug("Finish sending Small Scale Email. Publish Id is " + result);
            return result;
        }
示例#3
0
        /// <summary>
        /// send batch mail
        /// </summary>
        /// <param name="databaseName">databaseName</param>
        /// <param name="mailData">mailData</param>
        /// <returns></returns>
        public String sendBatchMail(String databaseName, MailData mailData)
        {
            logger.Debug("************send Batch Mail***************");
            String result = OK_RESULT;
            try
            {
                if (String.IsNullOrEmpty(databaseName))
                {
                    return "No database Name";
                }
                if (mailData == null || mailData.ContactJsonList == null || mailData.ContactJsonList.Count <= 0)
                {
                    return "No Contact";
                }
                ContactDatabaseAction contactDatabaseAction = new ContactDatabaseAction(client, userName, password, oWebProxy);
                String contactDatabaseId = contactDatabaseAction.createContactDatabase(databaseName);


                WorkspaceAction workspaceAction = new WorkspaceAction(client, userName, password, oWebProxy);
                String workspaceId = workspaceAction.createWorkspace(contactDatabaseId, databaseName);

                ContactDatabaseFieldAction contactDatabaseFieldAction = new ContactDatabaseFieldAction(client, userName, password, oWebProxy);
                Hashtable ht = contactDatabaseFieldAction.getContactDatabaseFields(contactDatabaseId);

                String toEmailFieldId; //Properties.Settings.Default.toEmailFieldId;// "MTExMzYxMTEfCGWCBaFKyA";
                if (ht[EMAIL] != null)
                {
                    toEmailFieldId = ht[EMAIL].ToString();
                }
                else
                {
                    return "Database:" + databaseName + " is not exist";
                }

                const string pattern = "\\{.+?\\}";
                List<string> tempList = Regex.Matches(mailData.mailBody, pattern).Cast<Match>().Select(a => a.Value).ToList();
                foreach (string str in tempList)
                {
                    mailData.mailBody = mailData.mailBody.Replace(str, str.ToLower());
                }
                //查找<A的html标记,如果里面没有title属性,则增加这个属性.
                mailData.mailBody = Util.addTitleInAFlagHtml(mailData.mailBody);


                String sequence = DateTime.Now.ToString("yyyyMMddhhmmss");
                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);

                // ContactGroup[] temp = contactGroupAction.getContactGroup(contactDatabaseId);

                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, "Mail Group" + sequence, "mail_group" + sequence);

                this.importContact(contactDatabaseId, contactGroupId, mailData);

                DirectEmailTypeAction directEmailTypeAction = new DirectEmailTypeAction(client, userName, password, oWebProxy);
                String directEmailTypeId = directEmailTypeAction.createDirectEmailType(workspaceId, "Email Type for" + databaseName, "mail_type_" + databaseName, mailData.fromAddress, mailData.sender, toEmailFieldId);

                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(directEmailTypeId, "Mail" + sequence, "mail" + sequence, mailData.subject, "Send mail", mailData.sender, mailData.fromAddress, mailData.mailBody);

                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);

                logger.Debug("publishId=" + publishId);

            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in send mail, error is " + result);

            }
            logger.Debug("************end sendMail ************");
            return result;
        }
示例#4
0
        public void sendMail(String EmailName, String groupId, String contactDatabaseId, String workspaceId, String emailTypeId, String fromName,
            String fromAddress, String reportReceiverAddress,  String subject, String htmlSource)
        {

            logger.InfoFormat("Begin sending mail for email " + EmailName);           

            //send test mail           
            this.sendNotification(contactDatabaseId, workspaceId, emailTypeId, reportReceiverAddress, subject+"[测试,请确认]", htmlSource);
            logger.InfoFormat("send test mail for email " + EmailName + " successfully");
           
            //Create Email
            DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
            String emailId = directEmailAction.createDirectEmail(emailTypeId, EmailName, EmailName, subject, "", fromName, fromAddress, htmlSource);
            logger.InfoFormat("Create email " + EmailName +  " successfully");

             return;
            //Publish Email
            logger.InfoFormat("Begin sending email  " + EmailName );            
            PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
            DateTime scheduleAt = DateTime.Now.AddMinutes(15);
            String publishId = publishingAction.publishingEmail(groupId, emailId, scheduleAt);
            Thread.Sleep(5 * 1000);
            while (true)
            {               
                publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                Job job = publishingAction.getPublishStatus(publishId);
                if (job.status.Contains("ENDED"))
                {                    
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("Sending Report");
                    sb.AppendLine("jobName=" + job.jobName);
                    sb.AppendLine("contactDatabaseLabel=" + job.contactDatabaseLabel);
                    sb.AppendLine("workspaceLabel=" + job.workspaceLabel);
                    sb.AppendLine("contactGroupLabel=" + job.contactGroupLabel);
                    sb.AppendLine("channel=" + job.channel);
                    sb.AppendLine("requestedNumberOfSend=" + job.requestedNumberOfSend);
                    sb.AppendLine("numberOfSend=" + job.numberOfSend);
                    sb.AppendLine("numberOfSkipped=" + job.numberOfSkipped);
                    

                   // Console.WriteLine(sb.ToString());
                    logger.InfoFormat("finish sending mail  " + EmailName + ", the sending status  is " + job.status + ", sending report is " + sb.ToString());
                    this.sendNotification(contactDatabaseId, workspaceId, emailTypeId, reportReceiverAddress, EmailName + "_邮件发送报告", sb.ToString());
                  
                    break;
                }
                logger.InfoFormat("Checking the sending status, and current sending status is " + job.status.ToString() + " for email: " + EmailName);
                Thread.Sleep(60 * 1000);
            }
            logger.InfoFormat("finish sending mail for email:" + EmailName);
        }
示例#5
0
        /// <summary>
        /// send batch mail
        /// </summary>
        /// <param name="databaseName">databaseName</param>
        /// <param name="mailData">mailData</param>
        /// <returns></returns>
        public String sendBatchMail(String contactDatabaseId,String workspaceId, String directEmailId,MailData mailData, DateTime scheduleAt)
        {
            logger.Debug("************send Batch Mail***************");
            String result = OK_RESULT;
            try
            {
                if (String.IsNullOrEmpty(contactDatabaseId))
                {
                    return "No database ";
                }
                if (mailData == null || mailData.ContactJsonList == null || mailData.ContactJsonList.Count <= 0)
                {
                    return "No Contact";
                }     

                //const string pattern = "\\{.+?\\}";
                //List<string> tempList = Regex.Matches(mailData.mailBody, pattern).Cast<Match>().Select(a => a.Value).ToList();
                //foreach (string str in tempList)
                //{
                //    mailData.mailBody = mailData.mailBody.Replace(str, str.ToLower());
                //}
                ////查找<A的html标记,如果里面没有title属性,则增加这个属性.
                //mailData.mailBody = Util.addTitleInAFlagHtml(mailData.mailBody);


                String sequence = DateTime.Now.ToString("yyyyMMddhhmmss");
                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);               

                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, "月度佣金" + sequence, "monthly_fee" + sequence);

                String importId= this.importContact(contactDatabaseId, contactGroupId, mailData);

                Thread.Sleep(5 * 1000);
                while (true)
                {
                    ImportContactAction importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                    importStatus status = importContactAction.getImportStatus(importId);

                    if (status.Equals(importStatus.ENDED))
                    {
                        logger.InfoFormat("import contact File  successfully");
                        break;
                    }
                    if (status.Equals(importStatus.STOPPED) || status.Equals(importStatus.ABORTED))
                    {
                        logger.InfoFormat("fail to import contact File  as import status is " + status.ToString());
                         throw new Exception("fail to import contact File  as import status is " + status.ToString());
                      
                        //break;
                    }
                    logger.InfoFormat("Checking the import status, and current import status is " + status.ToString() );
                    Thread.Sleep(5 * 1000);
                }

              
                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, scheduleAt);

                logger.Debug("publishId=" + publishId);
                result = "OK:"+publishId;

            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in send mail, error is " + result);
            }
            logger.Debug("************end sendMail ************");
            return result;
        }
示例#6
0
         /// <summary>
        /// publishing email
        /// </summary>
        /// <param name="contactGroupId">contact group id</param>
        /// <param name="emailId">email id</param>
        /// <returns>publish status</returns>
        public String publishingEmail(String contactGroupId, String emailId)
        {
            PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
           
            return publishingAction.publishingEmail(contactGroupId, emailId,DateTime.Now);

        }