CentralMine.NET.Email.SendErrorEmail C# (CSharp) Méthode

SendErrorEmail() public static méthode

public static SendErrorEmail ( string body ) : void
body string
Résultat void
        public static void SendErrorEmail(string body)
        {
            var fromAddress = new MailAddress("[email protected]", "From Name");
            var toAddress = new MailAddress("[email protected]", "To Name");
            const string fromPassword = "mandolin442";
            const string subject = "Mining Error";

            var smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };
            MailMessage message = new MailMessage(fromAddress, toAddress);
            message.Subject = subject;
            message.Body = body;
            smtp.Send(message);
        }

Usage Example

Exemple #1
0
        uint GetProductId(string product, uint memberId)
        {
            if (product.Length > 128)
            {
                product = product.Substring(0, 128);
            }

            if (!mProductIDs.ContainsKey(product))
            {
                string sql = "INSERT INTO products (product_name, member) VALUES ('" + product + "', '" + memberId + "')";
                try
                {
                    MySqlCommand cmd = new MySqlCommand(sql, mSql);
                    cmd.ExecuteNonQuery();

                    // Now querry the database for the index
                    sql = "SELECT * FROM products WHERE product_name='" + product + "'";
                    cmd = new MySqlCommand(sql, mSql);
                    MySqlDataReader r = cmd.ExecuteReader();
                    r.Read();
                    uint ID = (uint)r[0];
                    r.Close();
                    mProductIDs[product] = ID;
                }
                catch (Exception ex)
                {
                    Email.SendErrorEmail(sql + "\n\n" + ex.ToString());
                }
            }

            return(mProductIDs[product]);
        }
All Usage Examples Of CentralMine.NET.Email::SendErrorEmail