コード例 #1
0
            public void SendEmail_Renamed()
            {
                //Try

                MailMessage MailMsg = new MailMessage();

                MailMsg.From = this.Fra;
                MailMsg.To.Add(this.Til);
                if (SendToBCC)
                {
                    MailMsg.Bcc.Add(this.BCC);
                }

                MailMsg.BodyEncoding = this.BodyEncoding;
                MailMsg.Subject      = this.Subject;
                MailMsg.Body         = this.Body;
                MailMsg.Priority     = this.Priority;
                MailMsg.IsBodyHtml   = this.IsBodyHtml; //True
                MailMsg.DeliveryNotificationOptions = this.DeliveryNotificationOptions;
                if (this.Til.Address.ToString().IndexOf("test@") > 0)
                {
                    MailMsg.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
                }

                // attach each file attachment
                foreach (string strfile in this.FileList)
                {
                    if (!(strfile.Trim() == ""))
                    {
                        if (System.IO.File.Exists(strfile))
                        {
                            Attachment MsgAttach = new Attachment(strfile.Trim());
                            MailMsg.Attachments.Add(MsgAttach);
                        }
                    }
                }



                //Smtpclient to send the mail message
                SmtpClient SmtpMail = new SmtpClient();

                //SmtpMail.Host = SmtpURL
                SmtpMail.Send(MailMsg);

                Log.AddLog(status: "SendEmail", logtext: string.Format("Send - To: {0}, Subject: {1}", Til.ToString(), Subject), Metode: "SendEmail");

                //Message Successful
                //Catch ex As Exception
                //Message Error
                //End Try
            }