Ejemplo n.º 1
0
        public ActionResult Index(List <HttpPostedFileBase> files)
        {
            MailerAPI.MailSetting setting = new MailerAPI.MailSetting()
            {
                SmtpServer = "192.168.1.27",
                Port       = 25,
                UserName   = "******",
                Password   = "******"
            };
            MailerAPI.MailInfo info = new MailerAPI.MailInfo();
            info.Subject = "test";
            info.Body    = new System.Text.StringBuilder("test");
            info.To      = new List <string>()
            {
                "*****@*****.**"
            };
            if (files != null && files.Count > 0)
            {
                files.All(a =>
                {
                    if (a != null)
                    {
                        info.Files.Add(a.FileName, a.InputStream);
                    }
                    return(true);
                });
            }

            MailerAPI.Mailer mailer = new MailerAPI.Mailer(setting, info);
            mailer.SendMail();

            return(Content("Done"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 傳送Email
        /// </summary>
        /// <param name="totalProcessTime"></param>
        public void EmailSend(string dateGroup, string date)
        {
            var body = new StringBuilder();

            body.AppendLine(
                @"<p><span style=""color: #808080;""><strong>【" + date + " 電子發票資料比對清單】 </strong></span></p>");
            body.AppendLine(@"
                    <p><strong><span style=""color: #99cc00;"">核對日期:</span></strong>" + dateGroup + "</p>");

            #region B2C 開立

            body.AppendLine(@"
                    <p><strong><span style=""color: #99cc00;"">Einvoice[B2C-發票開立]未有資料清單如下</span></strong>,共 " + ValidMailBufferModel.B2CLostDataBuffer.Count + " 筆</p>");

            if (ValidMailBufferModel.B2CLostDataBuffer.Count > 0)
            {
                body.AppendLine(@"
                    <table style=""border:1px #ccc solid;"" cellpadding=""5"" border='1'>
                        <thead>
                            <tr>
                                <th style=""width: 162px;"">訂單號碼</th>
                                <th style=""width: 162px;"">發票號碼</th>
                                <th style=""width: 162px;"">訂單StartDate</th>
                            </tr>
                        </thead>
                        <tbody>");
                foreach (var item in ValidMailBufferModel.B2CLostDataBuffer)
                {
                    body.AppendLine(@"
                            <tr>
                                <td style=""width: 162px;"">" + item.OrderNo + @"</td>
                                <td style=""width: 162px;"">" + item.InvoiceNo + @"</td>
                                <td style=""width: 162px;"">" + item.StartDatetime.Value.ToString("yyyy\\/MM\\/dd") + @"</td>
                            </tr>");
                }

                body.AppendLine(@"
                        </tbody>
                    </table>");
            }

            #endregion B2C 開立

            #region B2B 開立

            body.AppendLine(@"
                    <p><strong><span style=""color: #99cc00;"">Einvoice[B2B-發票開立]未有資料清單如下</span></strong>,共 " + ValidMailBufferModel.B2BLostDataBuffer.Count + " 筆</p>");

            if (ValidMailBufferModel.B2BLostDataBuffer.Count > 0)
            {
                body.AppendLine(@"
                    <table style=""border:1px #ccc solid;"" cellpadding=""5"" border='1'>
                        <thead>
                            <tr>
                                <th style=""width: 162px;"">訂單號碼</th>
                                <th style=""width: 162px;"">發票號碼</th>
                                <th style=""width: 162px;"">訂單StartDate</th>
                            </tr>
                        </thead>
                        <tbody>");
                foreach (var item in ValidMailBufferModel.B2BLostDataBuffer)
                {
                    body.AppendLine(@"
                            <tr>
                      <td style=""width: 162px;"">" + item.OrderNo + @"</td>
                                <td style=""width: 162px;"">" + item.InvoiceNo + @"</td>
                                <td style=""width: 162px;"">" + item.StartDatetime.Value.ToString("yyyy\\/MM\\/dd") + @"</td>
                            </tr>");
                }
                body.AppendLine(@"
                        </tbody>
                    </table>");
            }

            #endregion B2B 開立

            #region B2C 作廢

            body.AppendLine(@"
                    <p><strong><span style=""color: #99cc00;"">Einvoice[B2C-發票作廢]未有資料清單如下</span></strong>,共 " + ValidMailBufferModel.B2CLostDropDataBuffer.Count + " 筆</p>");

            if (ValidMailBufferModel.B2CLostDropDataBuffer.Count > 0)
            {
                body.AppendLine(@"
                    <table style=""border:1px #ccc solid;"" cellpadding=""5"" border='1'>
                        <thead>
                            <tr>
                                <th style=""width: 162px;"">訂單號碼</th>
                                <th style=""width: 162px;"">發票號碼</th>
                                <th style=""width: 162px;"">訂單StartDate</th>
                            </tr>
                        </thead>
                        <tbody>");
                foreach (var item in ValidMailBufferModel.B2CLostDropDataBuffer)
                {
                    body.AppendLine(@"
                            <tr>
                      <td style=""width: 162px;"">" + item.OrderNo + @"</td>
                                <td style=""width: 162px;"">" + item.InvoiceNo + @"</td>
                                <td style=""width: 162px;"">" + item.StartDatetime.Value.ToString("yyyy\\/MM\\/dd") + @"</td>
                            </tr>");
                }
                body.AppendLine(@"
                        </tbody>
                    </table>");
            }

            #endregion B2C 作廢

            #region B2B 作廢

            body.AppendLine(@"
                    <p><strong><span style=""color: #99cc00;"">Einvoice[B2B-發票作廢]未有資料清單如下</span></strong>,共 " + ValidMailBufferModel.B2CLostDropDataBuffer.Count + " 筆</p>");

            if (ValidMailBufferModel.B2BLostDropDataBuffer.Count > 0)
            {
                body.AppendLine(@"
                    <table style=""border:1px #ccc solid;"" cellpadding=""5"" border='1'>
                        <thead>
                            <tr>
                                <th style=""width: 162px;"">訂單號碼</th>
                                <th style=""width: 162px;"">發票號碼</th>
                                <th style=""width: 162px;"">訂單StartDate</th>
                            </tr>
                        </thead>
                        <tbody>");
                foreach (var item in ValidMailBufferModel.B2BLostDropDataBuffer)
                {
                    body.AppendLine(@"
                            <tr>
                      <td style=""width: 162px;"">" + item.OrderNo + @"</td>
                                <td style=""width: 162px;"">" + item.InvoiceNo + @"</td>
                                <td style=""width: 162px;"">" + item.StartDatetime.Value.ToString("yyyy\\/MM\\/dd") + @"</td>
                            </tr>");
                }
                body.AppendLine(@"
                        </tbody>
                    </table>");
            }

            #endregion B2B 作廢

            //email通知
            MailerAPI.MailInfo mailInfo = new MailerAPI.MailInfo()
            {
                Subject = string.Format("[電子發票資料驗證通知系統]{0}通知明細", date),
                CC      = PublicStaticMethod.AdminEmail,
                Body    = body,
                To      = PublicStaticMethod.CurrentWorkflowMode == WorkflowTypeEnum.RELEASE ? PublicStaticMethod.AdminEmailGroup : PublicStaticMethod.AdminEmail
            };
            MailerAPI.Mailer mailer = new MailerAPI.Mailer(mailInfo);
            mailer.SendMail();
        }