コード例 #1
0
    protected void SendTestEmail(object sender, EventArgs e)
    {
        String email = tb_email.Text.Trim();

        if (Util.IsValidEmail(email))
        {
            String      password = (String)ViewState["pw"];
            MailMessage mail     = new MailMessage();
            mail         = Util.EnableSMTP(mail, email, password);
            mail.To      = email;
            mail.From    = email;
            mail.Subject = "Test e-mail from Dashboard's Gmail Manager";
            mail.Body    = "Test e-mail from Dashboard's Gmail Manager";

            try
            {
                SmtpMail.Send(mail);
                Util.PageMessageAlertify(this, "A test e-mail has been sent to " + Server.HtmlEncode(email), "Sent");
            }
            catch (Exception r)
            {
                if (r.Message.Contains("The transport error code was 0x80040217")) // wrong password
                {
                    Util.PageMessageAlertify(this, "The address/password combination you've specified are incorrect, please amend your credentials.", "Wrong Credentials");
                }
            }
        }
        else
        {
            Util.PageMessageAlertify(this, "Your e-mail address is not a valid format, please enter a correct format before continuing.", "Invalid E-mail");
        }
    }
コード例 #2
0
 bool IsValidEmail(string email)
 {
     try
     {
         myDAL        obj    = new myDAL();
         const string SERVER = "relay-hosting.secureserver.net";
         MailMessage  oMail  = new MailMessage();
         oMail.From          = "*****@*****.**";
         oMail.To            = email;
         oMail.Subject       = "Your Order Has Been Recieved";
         oMail.Body          = "Order Id: " + (obj.getorderid() + 1).ToString() + "\nThank You For Your Order.\nOur Representator will call you soon on the Provided Number.\nDetails: " + name + "\nPrice: " + price + "\nStatus: Not Confirmed.";
         oMail.Priority      = MailPriority.High; // enumeration
         SmtpMail.SmtpServer = SERVER;
         SmtpMail.Send(oMail);
         oMail.Subject = "An Order Has Been Placed At Livacorporations.com";
         oMail.Body    = "Order Id: " + (obj.getorderid() + 1).ToString() + "\nDetails: " + name + "\nPrice: " + price + "\nCustomer Details: \nName: " + TextBox1.Text + " " + TextBox2.Text + "\nCity: " + TextBox4.Text + "\nAddress: " + TextBox5.Text + "\nEmail: " + TextBox9.Text + "\nPhone: " + TextBox10.Text + "\nStatus: Not Confirmed.";
         for (int i = 0; i < arr.Length; i++)
         {
             oMail.To = arr[i];
             SmtpMail.Send(oMail);
         }
         oMail = null;   // free up resources
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
        public bool Send(string emailAddress, string password)
        {
            bool emailSend = false;

            try
            {
                if (!string.IsNullOrEmpty(emailAddress))
                {
                    MailMessage objMail = new MailMessage
                    {
                        From       = _email,
                        To         = emailAddress,
                        Subject    = "Forgot password",
                        BodyFormat = MailFormat.Html,
                        Priority   = MailPriority.High,
                        Body       = $"Your password is {password}"
                    };

                    SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
                    SmtpMail.Send(objMail);
                    emailSend = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(ex);
            }
            return(emailSend);
        }
コード例 #4
0
    protected void butsubmit_Click(object sender, EventArgs e)
    {
        cn.Open();
        string        str = "select password from personaldets1 where uid='" + txteid.Text + "'";
        SqlCommand    cmd = new SqlCommand(str, cn);
        SqlDataReader dr  = cmd.ExecuteReader();

        if (dr.Read())
        {
            lblerror.Text = dr[0].ToString();
            MailMessage msg = new MailMessage();
            msg.To      = txteid.Text;
            msg.From    = "*****@*****.**";
            msg.Subject = "Please check your Password";
            msg.Body    = lblalert.Text;
            SmtpMail.Send(msg);
            lblalert.Text    = "Your password Is Send To Your Mail";
            lblalert.Visible = true;
            lblerror.Visible = false;
        }
        else
        {
            lblerror.Text    = "Your Emailid is Incorrect";
            lblerror.Visible = true;
            lblalert.Visible = false;
        }
    }
コード例 #5
0
        private void cmdsend_Click(object sender, EventArgs e)
        {
            MailAttachment myattach   = new MailAttachment(txtattach.Text, MailEncoding.Base64);
            MailMessage    newmessage = new MailMessage();

            newmessage.From = txtfrom.Text;
            newmessage.To   = txtto.Text;
            if (txtcc.Text != "")
            {
                newmessage.Cc = txtcc.Text;
            }
            newmessage.Subject  = txtsubject.Text;
            newmessage.Priority = MailPriority.High;
            newmessage.Attachments.Add(myattach);
            newmessage.Body = txtbody.Text;
            try
            {
                SmtpMail.SmtpServer = f2server;
                SmtpMail.Send(newmessage);
                lblstatus.Text = "Send mail successful!";
            }
            catch (System.Web.HttpException)
            {
                lblstatus.Text = "Error send mail !!!";
            }
            txtto.Text      = "";
            txtcc.Text      = "";
            txtattach.Text  = "";
            txtsubject.Text = "";
            txtbody.Text    = "";
        }
コード例 #6
0
        public static void SendEmail(string smtpServer, string to, string from, string cc, string cco, string subject, string msg, System.Web.Mail.MailFormat format, string[] filesToAttach)
        {
            MailMessage msgMail = new MailMessage();

            msgMail.To          = to;
            msgMail.Cc          = cc;
            msgMail.Bcc         = cco;
            msgMail.From        = from;
            msgMail.Subject     = subject;
            msgMail.Body        = msg;
            msgMail.BodyFormat  = format;
            SmtpMail.SmtpServer = smtpServer;

            if (filesToAttach != null)
            {
                string file = string.Empty;

                for (int i = 0; i < filesToAttach.Length; i++)
                {
                    file = filesToAttach[i] as String;
                    msgMail.Attachments.Add(new MailAttachment(file, System.Web.Mail.MailEncoding.Base64));
                }
            }

            try
            {
                SmtpMail.Send(msgMail);
            }
            catch
            {
                // catch code here
            }
        }
コード例 #7
0
ファイル: Common.cs プロジェクト: va-vs/VAProjects
 /// <summary>
 /// WebMail发邮件
 /// </summary>
 /// <param name="fromMail">发件人邮箱地址</param>
 /// <param name="fromPwd">发件人邮箱密码</param>
 /// <param name="smtpStr">smtp服务器地址</param>
 /// <param name="toMail">收件人地址,支持群发,用";"隔开</param>
 /// <param name="subject">邮件主题</param>
 /// <param name="body">邮件正文</param>
 /// <param name="sendMode">邮件格式:0是纯文本,1是html格式化文本</param>
 /// <returns></returns>
 public static bool SendWebMail(string fromMail, string fromPwd, string smtpStr, string toMail, string subject, string body, string sendMode)
 {
     try
     {
         System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
         myMail.From = fromMail;
         myMail.To   = toMail;
         //myMail.Cc = ccMail;string ccMail, string bccMail,//抄送和密送
         //myMail.Bcc = bccMail;
         myMail.Subject    = subject;
         myMail.Body       = body;
         myMail.BodyFormat = sendMode == "0" ? MailFormat.Text : MailFormat.Html;
         //附件
         //string ServerFileName = "";
         //if (this.upfile.PostedFile.ContentLength != 0)
         //{
         //    string upFileName = this.upfile.PostedFile.FileName;
         //    string[] strTemp = upFileName.Split('.');
         //    string upFileExp = strTemp[strTemp.Length - 1].ToString();
         //    ServerFileName = Server.MapPath(DateTime.Now.ToString("yyyyMMddhhmmss") + "." + upFileExp);
         //    this.upfile.PostedFile.SaveAs(ServerFileName);
         //    myMail.Attachments.Add(new MailAttachment(ServerFileName));
         //}
         myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
         myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", fromMail); //发送方邮件帐户
         myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", fromPwd);  //发送方邮件密码
         SmtpMail.SmtpServer = smtpStr;                                                              //"smtp." + fromMail.Substring(fromMail.IndexOf("@") + 1);
         SmtpMail.Send(myMail);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #8
0
        public void SendAttachmentWithServer()
        {
            Console.WriteLine("=== Running SentAttachmentWithServer ===");
            Console.WriteLine("Sending mail to : " + toAddr);

            MailMessage message = new MailMessage();

            message.BodyFormat = MailFormat.Text;

            message.From = fromAddr;
            message.To   = toAddr;

            message.Subject = "Simias.Smtp SendAttachmentMail Test";

            // body
            message.Body = "This is the body of a message and there should be one attachment to this guy";

            MailAttachment attachment = new MailAttachment("smtptst1.gif");

            message.Attachments.Add(attachment);

            attachment = new MailAttachment("smtptst2.gif");
            message.Attachments.Add(attachment);

            // send
            if (!SmtpMail.Send(smtpHost, message))
            {
                throw new Exception("SendMail failed");
            }
        }
コード例 #9
0
ファイル: MailSend.cs プロジェクト: protecgithub/messina
        public void SendMailXls(string filename, DocType TipoDoc, int id_bl)
        {
            string FileName = filename;
            string maillist = "";

            //Recupero i destinatari legati all'edificio
            ArrayList li = GetDestinatariXls(id_bl);

            foreach (string mail in li)
            {
                maillist += mail + ";";
            }
            MailMessage mailMessage = new MailMessage();

            mailMessage.From       = ConfigurationSettings.AppSettings["MailFrom"].ToString();
            mailMessage.To         = maillist;
            mailMessage.Cc         = "*****@*****.**";
            mailMessage.Subject    = string.Format("Documento: {0} Data invio: {1} Ora: {2}", Path.GetFileName(FileName), DateTime.Now.ToLongDateString(), DateTime.Now.ToLongTimeString());
            mailMessage.Body       = "";
            mailMessage.BodyFormat = MailFormat.Html;

            MailAttachment attach = new MailAttachment(FileName);

            mailMessage.Attachments.Add(attach);
            //mailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
            mailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = ConfigurationSettings.AppSettings["usersmtp"].ToString();
            mailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = ConfigurationSettings.AppSettings["pwdsmtp"].ToString();

            SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["SmtpServer2"].ToString();
            SmtpMail.Send(mailMessage);
        }
コード例 #10
0
ファイル: Common.cs プロジェクト: va-vs/VAProjects
        public static bool SendMailWeb(string fromEmail, string fromPwd, string toEmail, string smtpServer, string title, string content)
        {
            try
            {
                System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
                myMail.From = fromEmail;
                myMail.To   = toEmail;// ;

                myMail.Subject    = title + DateTime.Now.ToString();
                myMail.Body       = content;
                myMail.BodyFormat = MailFormat.Html;

                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", fromEmail); //发送方邮件帐户
                myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", fromPwd);   //发送方邮件密码
                SmtpMail.SmtpServer = smtpServer;                                                            //"smtp." + fromMail.Substring(fromMail.IndexOf("@") + 1);
                SmtpMail.Send(myMail);
                return(true);
            }

            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #11
0
        /// <summary> 发送邮件 </summary>
        protected override void SendEmail()
        {
            var mail = ExceptionEmailConfigs.ConfigEntity;
            var smtp = new SmtpMail(mail.LoginName, mail.LoginPwd, mail.SendMail, "Farseer.Net SQL异常记录", mail.SmtpServer, 0, mail.SmtpPort);
            var body = new StringBuilder();

            body.AppendFormat("<b>发现时间:</b> {0}<br />", CreateAt.ToString("yyyy年MM月dd日 HH:mm:ss"));
            body.AppendFormat("<b>程序文件:</b> <u>{0}</u> <b>第{1}行</b> <font color=red>{2}()</font><br />", FileName, LineNo, MethodName);

            switch (CmdType)
            {
            case CommandType.StoredProcedure:
                body.AppendFormat("<b>存储过程:</b> {0}<br />", Name);
                break;

            case CommandType.Text:
                body.AppendFormat("<b>表视图名:</b> {0}<br />", Name);
                body.AppendFormat("<b>Sql语句:</b> {0}<br />", Sql);
                break;
            }

            body.AppendFormat("<b>Sql参数:</b><br />");
            SqlParamList.ForEach(o => body.AppendFormat("{0} = {1}<br />", o.Name, o.Value));
            body.AppendFormat("<b>错误消息:</b><font color=red>{0}</font><br />", Message);
            smtp.Send(mail.EmailAddress, $"{DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss")}:警告!数据库异常:{Message}", body.ToString());
        }
コード例 #12
0
    static public void Main(string[] args)
    {
        if (args.Length < 5 || (args.Length == 1 && (args[0] == "?" || args[0] == "/?" || args[0] == "-?" || args[0].ToLower() == "help")))
        {
            Console.WriteLine(usage);
        }
        else
        {
            try
            {
                string from    = args[2];
                string to      = args[1];
                string subject = args[3];
                string body    = args[4];
                SmtpMail.SmtpServer = args[0];
                SmtpMail.Send(from, to, subject, body);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return;
            }

            Console.WriteLine("Messaeg has been sent");
        }
    }
コード例 #13
0
ファイル: SendEmail.cs プロジェクト: msalah85/c-a-r-s
        public bool SendAnEmailAttch(string MsgTo, string Subj, string Body, string FileMsg)
        {
            bool IsSend = false;

            try
            {
                oMail.From          = from;
                oMail.To            = MsgTo;
                oMail.Bcc           = bcc;
                oMail.Subject       = Subj;
                oMail.BodyFormat    = MailFormat.Html;     // enumeration
                oMail.Priority      = MailPriority.Normal; // enumeration
                oMail.Body          = Body;
                SmtpMail.SmtpServer = SERVER;
                if (FileMsg.Length > 1)
                {
                    oMail.Attachments.Add(new MailAttachment(FileMsg));
                    //AttachFiles(FileMsg);
                }
                SmtpMail.Send(oMail);
                oMail  = null;// free up resources
                IsSend = true;
            }
            catch
            {
                IsSend = false;
            }
            return(IsSend);
        }
コード例 #14
0
        private void SendButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                MailMessage aMessage = new MailMessage();
                aMessage.From    = FromTextBox.Text;
                aMessage.To      = ToTextBox.Text;
                aMessage.Cc      = CCTextBox.Text;
                aMessage.Bcc     = BCCTextBox.Text;
                aMessage.Subject = SubjectTextBox.Text;
                aMessage.Body    = MessageTextBox.Text;
                if (AttachmentTextBox.Text.Length > 0)
                {
                    aMessage.Attachments.Add(new MailAttachment(AttachmentTextBox.Text, MailEncoding.Base64));
                }

                SmtpMail.Send(aMessage);

                MessageBox.Show("Óʼþ·¢Ëͳɹ¦£¡");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #15
0
 protected void btnEmail_Click1(object sender, EventArgs e)
 {
     /*	if(lblEmail.Text=="")
      * {
      *  lblMessage.Text="We were unable to send an email confirmation. You didn’t provide an email address.";
      *  lblMessage.ForeColor= System.Drawing.Color.Red;
      * }
      * else
      * {    */
     try
     {
         string strTo      = "*****@*****.**";//Convert.ToString(Session["email"]);
         string strFrom    = "*****@*****.**";
         string strSubject = "Burning Permit Notification";
         SmtpMail.SmtpServer = "mail.topeka.org";
         SmtpMail.Send(strFrom, strTo, strSubject,
                       "The Topeka Fire Department has received your request for an inspection. \n" +
                       "NOTE: THIS IS NOT THE ACUTAL PERMIT \n" +
                       "On the day you wish to burn, notify Topeka Fire Department at 785-368-9514 before and after burning. \n" +
                       "For all other issues or questions concerning this request please call 785-368-4000. \n" +
                       "If you are unable to sign the permit at the burning location, then you will need to pick up your permit at: \n" +
                       "Topeka Fire Academy \n" +
                       "324 SE Jefferson \n" +
                       "Topeka , KS 66607 \n\n" +
                       //"Permit Number: " + lblPermitNumber.Text+ "\n"+ "Issue Date: " +lblIssueDate.Text + "\n" + "Burn Address: " +lblBurningAddress.Text +
                       "\n\nNOTE: If you are going to pick up the permit you have TWO weeks after the issue date to pick up the permit.  If you fail to pick up the permit within these two weeks you must reapply for another permit.");
     }
     catch (Exception ex)
     {
         string test;
         test = ex.ToString();
     }
     //	}
 }
コード例 #16
0
        /// <summary>Envia um mail</summary>
        public static bool Send(MailMessage message)
        {
            try {
                if (message.From == null || message.From == "")
                {
                    message.From = Mailer.From;
                }

#if DEBUG_MAIL
                Log.log("----- SEND MAIL DEBUG ----------");
                Log.log("To: {0}", message.To);
                Log.log("From: {0}", message.From);
                Log.log("Bcc: {0}", message.Bcc);
                Log.log("Title: {0}", message.Subject);
                Log.log("Message: {0}", message.Body);
                Log.log("-------------------------------");
#endif

                Log.log("Sending mail message '{0}'...", message.Subject);
                SmtpMail.Send(message);
                Log.log("... Done!");
                return(true);
            } catch (System.Exception e) {
                ExceptionLog.log(e, false);
                return(false);
            }
        }
コード例 #17
0
    public bool sendEmail(string subject, string fromMail, string tomail, string cc, string body)
    {
        string      message = "";
        MailMessage msgMail = new MailMessage();

        msgMail.To      = tomail;
        msgMail.Bcc     = cc;
        msgMail.From    = fromMail;
        msgMail.Subject = subject;

        message  = "<html><head></head><body>";
        message += body;
        message += " </body></html>";

        msgMail.BodyFormat = MailFormat.Html;
        msgMail.Body       = message;

        try
        {
            SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
            SmtpMail.Send(msgMail);
        }
        catch (Exception er) { return(false); }

        return(true);
    }
コード例 #18
0
ファイル: CrashGuard.cs プロジェクト: proxeeus/UORebirth
        private static void SendEmail(string filePath)
        {
            Console.Write("Crash: Sending email...");

            try
            {
                MailMessage message = new MailMessage();

                message.Subject = "Automated RunUO Crash Report";
                message.From    = "RunUO";
                message.To      = Emails;
                message.Body    = "Automated RunUO Crash Report. See attachment for details.";

                message.Attachments.Add(new MailAttachment(filePath));

                SmtpMail.SmtpServer = EmailServer;
                SmtpMail.Send(message);

                Console.WriteLine("done");
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
コード例 #19
0
        protected void ButtonSubmit_Click(object sender, System.EventArgs e)
        {
            Server.ScriptTimeout = 1000;
            Response.Flush();

            SmtpMail.SmtpServer = "localhost";
            MailMessage mail = new MailMessage();

            mail.To      = this.TextBoxTo.Text;
            mail.Cc      = this.TextBoxCc.Text;
            mail.Bcc     = this.TextBoxBcc.Text;
            mail.From    = this.TextBoxFrom.Text;
            mail.Subject = this.TextBoxSubject.Text;
            mail.Body    = this.TextBoxBody.Text;

            try
            {
                SmtpMail.Send(mail);
                Response.Write("<p><strong> The Mail has been sent to: </strong></p>");
                Response.Write("&bull; To:&nbsp;&nbsp;&nbsp;" + mail.To + "</br>");
                Response.Write("&bull; Cc:&nbsp;&nbsp;&nbsp;" + mail.Cc + "</br>");
                Response.Write("&bull; Bcc:&nbsp;&nbsp;" + mail.Bcc + "</br>");
            }
            catch (System.Exception ex)
            {
                Response.Write("<p><strong>An erros has occured: " + ex.Message + "</strong><p>");
            }

            Response.Flush();
        }
コード例 #20
0
    protected void SendEmail()
    {
        String         mail_to = Util.GetMailRecipientsByRoleName("db_leads", null, null);
        StringWriter   sw      = new StringWriter();
        HtmlTextWriter hw      = new HtmlTextWriter(sw);

        gv_analytics.RenderControl(hw);

        MailMessage mail = new MailMessage();

        mail = Util.EnableSMTP(mail);
        if (mail_to != String.Empty)
        {
            mail.To         = mail_to; //"[email protected]; ";
            mail.From       = "[email protected];";
            mail.Subject    = "Weekly DataGeek Leads Statistics";
            mail.BodyFormat = MailFormat.Html;
            mail.Body       = "<html><head></head><body style=\"font-family:Verdana; font-size:8pt;\">Please review the DataGeek Leads Statistics for last week (Saturday " + from.ToString().Substring(0, 10)
                              + " to Friday " + to.AddDays(-1).ToString().Substring(0, 10) + ", up to midnight).<br/>These stats cover only Leads <i>added</i> to the system within last week.<br/><br/>" + sw.ToString() +
                              "<br/><hr/>This is an automated message from the DataGeek Leads Analytics page." +
                              "<br><br>This message contains confidential information and is intended only for the " +
                              "individual named. If you are not the named addressee you should not disseminate, distribute " +
                              "or copy this e-mail. Please notify the sender immediately by e-mail if you have received " +
                              "this e-mail by mistake and delete this e-mail from your system. E-mail transmissions may contain " +
                              "errors and may not be entirely secure as information could be intercepted, corrupted, lost, " +
                              "destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept " +
                              "liability for any errors or omissions in the contents of this message which arise as a result of " +
                              "e-mail transmission.</td></tr></table></body></html>";

            try { SmtpMail.Send(mail); }
            catch { }
        }
    }
コード例 #21
0
ファイル: Utility.cs プロジェクト: BInny1/mobileservice
        /// <summary>
        /// Generic function to send mail
        /// </summary>
        /// <param name="smtpServer">SMTP Server Name/IP</param>
        /// <param name="from">From Email Address</param>
        /// <param name="to">To Email Address</param>
        /// <param name="subject">Subject</param>
        /// <param name="body">Body</param>
        /// <returns>bool</returns>
        public bool SendMail(string strSmtpServer, string strFrom, string strTo, string strSubject, string strBody)
        {
            MailMessage mailMsg     = null;
            Boolean     blnMailSent = false;

            try
            {
                mailMsg            = new MailMessage();
                mailMsg.From       = strFrom;
                mailMsg.To         = strTo;
                mailMsg.Cc         = strFrom;
                mailMsg.Subject    = strSubject;
                mailMsg.BodyFormat = MailFormat.Html;
                mailMsg.Body       = strBody;

                if (strSmtpServer.Trim().Length != 0)
                {
                    SmtpMail.SmtpServer = strSmtpServer;
                }
                SmtpMail.Send(mailMsg);
                blnMailSent = true;
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, Global.EXCEPTION_POLICY);

                if (rethrow)
                {
                    throw;
                }
            }
            return(blnMailSent);
        }
コード例 #22
0
ファイル: dbutil.cs プロジェクト: radtek/E-FAB_DOTNET
    public void sendMail(string Mail_Body, string Mail_To, string Mail_Subject)
    {
        MailMessage objMailMessage = new MailMessage();
        SmtpMail    objmail;

        objMailMessage.BodyFormat = MailFormat.Html;
        objMailMessage.Body       = Mail_Body;
        objMailMessage.To         = Mail_To;
        objMailMessage.From       = "*****@*****.**";
        objMailMessage.Subject    = Mail_Subject;

        try
        {
            SmtpMail.SmtpServer = "10.56.130.63";
            SmtpMail.Send(objMailMessage);
        }
        catch
        {
            try
            {
                SmtpMail.SmtpServer = "10.56.130.57";
                SmtpMail.Send(objMailMessage);
            }
            catch
            {
            }
        }
    }
コード例 #23
0
        /// <summary>
        /// Attachment_flag=1 true else false
        /// if Attachment_flag=1 then file_path=absolutely path   else absolutely path=null
        /// </summary>
        /// <param name="mail_body"></param>
        /// <param name="mail_from"></param>
        /// <param name="mail_to"></param>
        /// <param name="mail_cc"></param>
        /// <param name="mail_subject"></param>
        /// <param name="Attachment_flag">Attachment_flag=1 true else false</param>
        /// <param name="file_path">absolutely path</param>

        public void Send_mail(string mail_body, string mail_from, string mail_to, string mail_cc, string mail_subject, int Attachment_flag, string file_path)
        {
            MailMessage Message = new MailMessage();

            Message.BodyEncoding = Encoding.UTF8;
            Message.To           = mail_to;
            Message.Cc           = mail_cc;

            if (Attachment_flag == 1)
            {
                MailAttachment ma = new MailAttachment(file_path);

                Message.Attachments.Add(ma);
            }
            else
            {
                Message.Attachments.Clear();
            }
            Message.From    = mail_from;
            Message.Subject = mail_subject;

            Message.BodyFormat = MailFormat.Html;
            Message.Body       = mail_body;
            try
            {
                SmtpMail.Send(Message);
            }
            catch
            {
                SmtpMail.SmtpServer = System.Configuration.ConfigurationSettings.AppSettings["MAIL_SERVER_bak"];
                SmtpMail.Send(Message);
            }
        }
コード例 #24
0
        public bool Send(string emailAddress)
        {
            bool emailSend = false;

            try
            {
                if (!string.IsNullOrEmpty(emailAddress))
                {
                    MailMessage objMail = new MailMessage
                    {
                        From       = _email,
                        To         = emailAddress,
                        Subject    = "Forgot password",
                        BodyFormat = MailFormat.Html,
                        Priority   = MailPriority.High,
                        Body       = $"Your order is confirmed and soon will be delivered to your registered address. Thank You."
                    };

                    SmtpMail.SmtpServer = "relay-hosting.secureserver.net";
                    SmtpMail.Send(objMail);
                    emailSend = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(ex);
            }
            return(emailSend);
        }
コード例 #25
0
ファイル: Mails.cs プロジェクト: ZPMAI/OCR_WebAPI
        public void Send()
        {
            MailMessage mailMessage = new MailMessage();

            mailMessage.From = mailfrom;
            mailMessage.To   = mailto;
            //mailMessage.Cc = mailcc;
            mailMessage.Subject    = subject;
            mailMessage.Body       = body;
            mailMessage.BodyFormat = MailFormat.Text;
            mailMessage.Priority   = MailPriority.High;

            mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", server);
            mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", username);
            mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);

            if ((this.attachments != null) &&
                (this.attachments.Length > 0))
            {
                foreach (string attachment in attachments)
                {
                    MailAttachment mailAttachment = new MailAttachment(attachment);
                    mailMessage.Attachments.Add(mailAttachment);
                }
            }

            SmtpMail.SmtpServer = server;
            SmtpMail.Send(mailMessage);
        }
コード例 #26
0
ファイル: forward.aspx.cs プロジェクト: agailevictor/eleave2
        private bool SendWebMail(string strTo, string subj, string cont, string cc, string bcc, string strfrom)
        {
            bool        flg = false;
            MailMessage msg = new MailMessage();

            msg.Body       = cont;
            msg.From       = strfrom;
            msg.To         = strTo;
            msg.Subject    = subj;
            msg.Cc         = cc;
            msg.Bcc        = bcc;
            msg.BodyFormat = MailFormat.Html;
            try
            {
                //SmtpMail.SmtpServer = "175.143.44.165";
                SmtpMail.SmtpServer = "192.168.1.4"; // change the ip address to this when hosting in server
                SmtpMail.Send(msg);
                flg = true;
            }
            catch (Exception)
            {
                flg = false;
            }
            return(flg);
        }
コード例 #27
0
        public static void Main()
        {
            MailAttachment myattach =
                new MailAttachment("c:\\temp\\MailAttachTest.exe", MailEncoding.Base64);
            MailMessage newmessage = new MailMessage();

            newmessage.From     = "*****@*****.**";
            newmessage.To       = "*****@*****.**";
            newmessage.Subject  = "A test mail attachment message";
            newmessage.Priority = MailPriority.High;
            newmessage.Headers.Add("Comments",
                                   "This message attempts to send a binary attachment");
            newmessage.Attachments.Add(myattach);
            newmessage.Body = "Here's a test file for you to try";

            try
            {
                SmtpMail.SmtpServer = "192.168.1.100";
                SmtpMail.Send(newmessage);
            }
            catch (System.Web.HttpException)
            {
                Console.WriteLine("This device can not send Internet messages");
            }
        }
コード例 #28
0
 public static void SendMail(string to, string bbc, string subject, string messages, string smtp, string port, string from, string user, string password)
 {
     try
     {
         System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
         mail.To           = to;
         mail.Bcc          = bbc;
         mail.From         = from;
         mail.Subject      = subject;
         mail.BodyEncoding = Encoding.GetEncoding("utf-8");
         mail.BodyFormat   = MailFormat.Html;
         mail.Body         = messages;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]      = 2;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"]     = smtp;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = port;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"]     = 1;             // "true";
         //mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"] = 60;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]     = user;
         mail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]     = password;
         SmtpMail.Send(mail);
     }
     catch (Exception)
     {
         HttpContext.Current.Response.Redirect("/InnerError.html", false);
     }
 }
コード例 #29
0
        public static bool DoSendMail(string server, string user, string password, string from, string to, string cc, string subject, string content)
        {
            MailMessage message = new MailMessage();

            message.To           = to;
            message.From         = from;
            message.Cc           = cc;
            message.Subject      = subject;
            message.BodyEncoding = Encoding.UTF8;
            message.BodyFormat   = MailFormat.Html;
            message.Body         = content;
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", server);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", user);
            message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);

            try
            {
                SmtpMail.Send(message);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #30
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        // get password from database//

        string strpassword = "******";



        MailMessage msgMail = new MailMessage();

        msgMail.To = txtemail.Text;

        msgMail.From    = "*****@*****.**";
        msgMail.Subject = "Your Password has been sended." + strpassword;

        msgMail.BodyFormat = MailFormat.Html;
        string strbody = "<b>Hello World</b>" +
                         " <font color=\"red\">Your Password is:" + strpassword + "</font>";

        msgMail.Body = strbody;

        //SmtpMail.SmtpServer = "mail.dotnetexpert.info";

        SmtpMail.Send(msgMail);

        lblmessage.Text = "Password successfully sent to your emil address...";
    }
コード例 #31
0
ファイル: SqlErrorLog.cs プロジェクト: FarseerNet/Farseer.Net
        /// <summary> 发送邮件 </summary>
        private void SendEmail()
        {
            var mail = ExceptionEmailConfigs.ConfigEntity;
            var smtp = new SmtpMail(mail.LoginName, mail.LoginPwd, mail.SendMail, "Farseer.Net SQL异常记录", mail.SmtpServer, 0, mail.SmtpPort);
            var body = new StringBuilder();
            body.AppendFormat("<b>发现时间:</b> {0}<br />", CreateAt);
            body.AppendFormat("<b>程序文件:</b> <u>{0}</u> <b>第{1}行</b> <font color=red>{2}()</font><br />", FileName, LineNo, MethodName);

            switch (CmdType)
            {
                case CommandType.StoredProcedure:
                    body.AppendFormat("<b>存储过程:</b> {0}<br />", Name);
                    break;
                case CommandType.Text:
                    body.AppendFormat("<b>表视图名:</b> {0}<br />", Name);
                    body.AppendFormat("<b>Sql语句:</b> {0}<br />", Sql);
                    break;
            }

            body.AppendFormat("<b>Sql参数:</b><br />");
            SqlParamList.ForEach(o => body.AppendFormat("{0} = {1}<br />", o.Name, o.Value));
            body.AppendFormat("<b>错误消息:</b><font color=red>{0}</font><br />", Message);
            smtp.Send(mail.EmailAddress, $"{DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss")}:警告!数据库异常:{Message}", body.ToString());
        }