コード例 #1
0
        private void Messaging_ReadEventHandler(object sender, EventArgs e)
        {
            log.Info("Messaging_ReadEventHandler starts here");
            try
            {
                KirimModel  model       = (KirimModel)e;
                MailMessage mailMessage = new MailMessage();
                mailMessage.To.Add(new MailAddress(ConfigurationManager.AppSettings["Mail_To"].ToString(), ConfigurationManager.AppSettings["Mail_To_DisplayName"].ToString()));
                mailMessage.From       = new MailAddress(ConfigurationManager.AppSettings["Mail_From"].ToString(), ConfigurationManager.AppSettings["Mail_From_DisplayName"].ToString());
                mailMessage.Subject    = "Anda Mendapat Pesan Dari " + model.Name + " - www.anasbimbel.com";
                mailMessage.IsBodyHtml = true;
                mailMessage.Body       = GetTemplage(model);

                SmtpClient smtpClient = new SmtpClient();
                smtpClient.Host           = ConfigurationManager.AppSettings["SMTP_Host"].ToString();
                smtpClient.Port           = Int32.Parse(ConfigurationManager.AppSettings["SMTP_Port"].ToString());
                smtpClient.Credentials    = new NetworkCredential(ConfigurationManager.AppSettings["SMTP_Username"].ToString(), ConfigurationManager.AppSettings["SMTP_Password"].ToString());
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.DeliveryFormat = SmtpDeliveryFormat.International;
                smtpClient.Send(mailMessage);

                log.Info("Kirim Pesan Dari " + model.Email);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            log.Info("Messaging_ReadEventHandler stops here");
        }
コード例 #2
0
        private string GetTemplage(KirimModel model)
        {
            StringBuilder template = new StringBuilder();

            template.Append(@"<table width=""800"" border=""0"" cellpadding=""0"" cellspacing=""0"">");
            template.Append(@"<tr>");
            template.Append(@"<td width=""110"">Nama</td>");
            template.Append(@"<td width=""20"">&nbsp;:&nbsp;</td>");
            template.Append(@"<td>");
            template.Append(@"<b>" + model.Name + "</b>");
            template.Append(@"</td>");
            template.Append(@"</tr>");
            template.Append(@"<tr>");
            template.Append(@"<td width=""110"">Email</td>");
            template.Append(@"<td width=""20"">&nbsp;:&nbsp;</td>");
            template.Append(@"<td>");
            template.Append(@"<b>" + model.Email + "</b>");
            template.Append(@"</td>");
            template.Append(@"</tr>");
            template.Append(@"<tr>");
            template.Append(@"<td width=""110"">Telephone</td>");
            template.Append(@"<td width=""20"">&nbsp;:&nbsp;</td>");
            template.Append(@"<td>");
            template.Append(@"<b>" + model.Telephone + "</b>");
            template.Append(@"</td>");
            template.Append(@"</tr>");
            template.Append(@"<tr>");
            template.Append(@"<td width=""110"" valign=""top"">Pesan</td>");
            template.Append(@"<td width=""20"" valign=""top"">&nbsp;:&nbsp;</td>");
            template.Append(@"<td>");
            template.Append(@"<b>" + model.Message + "</b>");
            template.Append(@"</td>");
            template.Append(@"</tr>");
            template.Append(@"<tr><td colspan=""3"" height=""40"">&nbsp;&nbsp;</td></tr>");
            template.Append(@"<tr>");
            template.Append(@"<td colspan=""3"" align=""center"">");
            template.Append(@"<a href=""mailto:" + model.Email + @"?subject=" + model.Subject + @""" target=""_self"" style=""width:200px;padding:10px;border:2px solid #d9d9d9;"">BALAS</a>");
            template.Append(@"</td>");
            template.Append(@"</tr>");
            template.Append(@"</table>");
            return(template.ToString());
        }
コード例 #3
0
        public async Task <bool> Kirim(KirimModel model)
        {
            bool result = await Task.Run <bool>(() => {
                MSMQModel <KirimModel> newmodel = new MSMQModel <KirimModel>();
                newmodel.QueueMessage           = model;
                newmodel.QueueName     = ConfigurationManager.AppSettings["Queue_Name"].ToString();
                MSMQ <KirimModel> msmq = new MSMQ <KirimModel>();
                msmq.WriteQueueMessage(newmodel);

                SMSMessage message = new SMSMessage();
                message.Message    = message.Message.Replace("{PENGIRIM}", model.Name).Replace("{NEWLINE}", Environment.NewLine + Environment.NewLine);

                SMS sms     = new SMS();
                sms.Message = message;
                sms.Send();
                return(true);
            });

            return(result);
        }