コード例 #1
0
ファイル: EmailService.cs プロジェクト: sunjayp888/Nidan
        public void SendEmail(EmailData data)
        {
            UseOverrideEmailDataIfSet(data);

            var client = new EmailServiceClient();

            client.SendEmail(data);
        }
コード例 #2
0
        public bool SendMessage(EmailMessage email)
        {
            var client = new EmailServiceClient();
            var to     = email.To.Split(';');

            var result = client.SendEmail(to, email.From, email.Subject, email.Body, true, "Normal", new string[] { "" }, new string[] { "" });

            return(result);
        }
コード例 #3
0
 public static void SendEmail(EmailTemplate email)
 {
     //add a try catch exception here
     var client = new EmailServiceClient();
     client.SendEmail(new EmailService.Email()
     {
         Body = email.Body,
         FromEmailAddress = email.FromEmailAddress,
         FromName = email.FromName,
         Subject = email.Subject,
         ToEmailAddress = email.ToEmailAddress,
         ToName = email.ToName
     });
 }
コード例 #4
0
        private void SendEmail(string btncommand)
        {
            try
            {
                var attachments = new List <FileAttachment>();
                if (fileAttachment.HasFile)
                {
                    var file = new FileAttachment
                    {
                        Name    = fileAttachment.FileName,
                        Content = Convert.ToBase64String(fileAttachment.FileBytes)
                    };
                    attachments.Add(file);
                }


                var request = new SendEmailRequest
                {
                    Body             = this.txtBody.Text,
                    FromEmailAddress = String.IsNullOrEmpty(this.txtFromEmail.Text) ? null : this.txtFromEmail.Text,
                    Recipients       = String.IsNullOrEmpty(this.txtTo.Text) ? null : this.txtTo.Text.Split(';'),
                    CarbonCopyList   = String.IsNullOrEmpty(this.txtCC.Text) ? null : this.txtCC.Text.Split(';'),
                    SessionId        = "6C06251C-377E-4803-A96F-5CC10490748B",
                    Subject          = this.txtSubject.Text,
                    Attachments      = attachments.Count > 0 ? attachments.ToArray() : null
                };
                System.Net.ServicePointManager.ServerCertificateValidationCallback =
                    ((sender, certificate, chain, sslPolicyErrors) => true);

                if (btncommand == "Sendmail")
                {
                    using (var proxy = new EmailServiceClient())
                    {
                        var response = proxy.SendEmail(request);
                        if (response != null && response.IsSuccess)
                        {
                            this.errorText.Visible = true;
                            this.errorText.Text    = "Email succeeded.";
                            return;
                        }
                        this.errorText.Visible = true;
                        this.errorText.Text    = "Email failed.";
                    }
                }

                else
                {
                    using (var proxy = new EmailServiceClient())
                    {
                        var response = proxy.SendEmailWithBadAddressCheck(request);
                        if (response != null && response.IsSuccess)
                        {
                            this.errorText.Visible = true;
                            this.errorText.Text    = "Email succeeded.";
                        }
                        else
                        {
                            this.errorText.Visible = true;
                            this.errorText.Text    = "Email failed.";
                        }
                        if (response.InvalidRecipients.BadDomains.Count() != 0)
                        {
                            this.errorText.Text += String.Format("\t Email address with bad domains list:-\t {0}", String.Join(",", response.InvalidRecipients.BadDomains));
                        }
                    }
                }
            }
            catch (FaultException <EmailServiceFault> fxException)
            {
                this.errorText.Visible = true;
                this.errorText.Text    = fxException.Detail.ToString();
            }
            catch (Exception ex)
            {
                this.errorText.Visible = true;
                this.errorText.Text    = ex.Message + ex.StackTrace;
            }
        }
コード例 #5
0
        public void SendMessage(String pMessage, String address)
        {
            EmailServiceClient lClient = new EmailServiceClient();

            lClient.SendEmail(pMessage, address);
        }