Dispose() public method

public Dispose ( ) : void
return void
Example #1
0
        public bool SendMail(string fromAddress, string toAddress, string subject, string body)
        {
            var mail = new MailMessage(fromAddress, toAddress, subject, body);
            mail.IsBodyHtml = true;
            bool success = false;
            var mailSettings = Helpers.GetConfigSectionGroup<MailSettingsSectionGroup>("system.net/mailSettings");
            var pickupDir = mailSettings != null &&
                            mailSettings.Smtp != null &&
                            mailSettings.Smtp.SpecifiedPickupDirectory != null ?
                            mailSettings.Smtp.SpecifiedPickupDirectory.PickupDirectoryLocation : null;

            if (!string.IsNullOrWhiteSpace(pickupDir) && !Directory.Exists(pickupDir))
            {
                Directory.CreateDirectory(pickupDir);
            }

            try
            {
                this._smtpClient.Send(mail);
                success = true;
                mail.Dispose();
            }
            catch (Exception ex)
            {
                mail.Dispose();
                Logger.Log(string.Format("An error occurred while trying to send a mail with subject {0} to {1}.", mail.Subject, mail.To), ex, LogLevel.Error);

                throw;
            }

            return success;
        }
Example #2
0
        public string SendEmail(string Recip, string Url)
        {

            System.Net.Mail.MailMessage Email = new System.Net.Mail.MailMessage();
            try
            {

                var appSettings = ConfigurationManager.AppSettings;
                bool BSsl = Convert.ToBoolean(appSettings["Ssl_correo"]);


                MailAddress from = new MailAddress(appSettings["UserName_correo"], "IST");
                Email.To.Add(Recip);

                Email.Subject = appSettings["Subject"];
                Email.SubjectEncoding = System.Text.Encoding.UTF8;
                Email.Body = appSettings["Body"];
                Email.BodyEncoding = System.Text.Encoding.UTF8;
                Email.IsBodyHtml = false;
                Email.Attachments.Add(new Attachment(Url));
                Email.From = from;
                System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();
                cliente.Port = Convert.ToInt16(appSettings["Puerto_correo"]);
                cliente.UseDefaultCredentials = true;
                cliente.Credentials = new System.Net.NetworkCredential(appSettings["UserName_correo"], appSettings["Password_correo"]);
                cliente.Host = appSettings["server_correo"];
                cliente.EnableSsl = BSsl;
                cliente.Send(Email);

                Email.Dispose();
                return "OK";
            }
            catch (SmtpException ex)
            {
                Email.Dispose();
                return (ex.Message + "Smtp.");
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Email.Dispose();
                return "Sending Email Failed. Check Port Number.";
            }
            catch (InvalidOperationException Ex)
            {
                Email.Dispose();
                return "Sending Email Failed. Check Port Number.";
            }

           
        }
        public string sendGmail(string name, string userEmail, string value)
        {
            string reciverEmail = "[email protected]";
            string content = "'" + name + "' send a new message from AutoTutor Website\n\n Email address: " + userEmail + "\n\n Message content: " + value;
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress(reciverEmail);
            msg.To.Add(reciverEmail);
            msg.Subject = "From AutoTutor Website! " + DateTime.Now.ToString();
            msg.Body = content;
            SmtpClient client = new SmtpClient();
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(reciverEmail, "TNMemFIT410");
            client.Timeout = 20000;
            try
            {
                client.Send(msg);
                return "Mail has been successfully sent!";
            }
            catch (Exception ex)
            {
                return "Fail Has error" + ex.Message;
            }
            finally
            {
                msg.Dispose();
            }
        }
Example #4
0
        // Отправка сообщения на почту
        public static async Task Send(Request request)
        {
            var body = "<p>Саня, на нашем сайте заявка от человека с именем, {0} {1}!</p><pЕму можно позвонить по номеру:{2}<br>Его почта: {3}</p>";
            var message = new MailMessage();
            message.To.Add(new MailAddress(MailRecipient));  // replace with valid value 
            message.From = new MailAddress(MailSender);  // replace with valid value
            message.Subject = "Вы оставили заявку на нашем сайте";
            message.Body = string.Format(body, request.FirstName, request.LastName, request.PhoneNumber, request.MiddleName);

            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = MailSender,  // replace with valid value
                    Password = "SmolinaBreakBeat12357895"  // replace with valid value
                };

                smtp.Credentials = credential;
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.EnableSsl = true;
                await smtp.SendMailAsync(message);
                message.Dispose();
            }
        }
Example #5
0
 public bool SendMessage(string from, string to,
      string subject, string body)
 {
     MailMessage mailMessage = null;
     bool isSent = false;
     try
     {
         mailMessage = new MailMessage(from, to, subject, body);
         mailMessage.DeliveryNotificationOptions = 
                DeliveryNotificationOptions.OnFailure;
         // Send it
         
         _client.Send(mailMessage);
         isSent = true;
     }
     // Catch any errors, these should be logged 
     catch (Exception ex)
     {
         
     }
     finally
     {
         mailMessage.Dispose();
     }
     return isSent;
 }
Example #6
0
        public ActionResult SendForm(EmailInfoModel emailInfo)
        {
            try
            {
                MailMessage msg = new MailMessage(CloudConfigurationManager.GetSetting("EmailAddr"), "[email protected]");
                var smtp = new SmtpClient("smtp.gmail.com", 587)
                {

                    Credentials = new NetworkCredential(CloudConfigurationManager.GetSetting("EmailAddr"), CloudConfigurationManager.GetSetting("EmailKey")),
                    EnableSsl = true
                };

                StringBuilder sb = new StringBuilder();
                msg.To.Add("[email protected]");
                msg.Subject = "Contact Us";
                msg.IsBodyHtml = false;

                sb.Append(Environment.NewLine);
                sb.Append("Email: " + emailInfo.Email);
                sb.Append(Environment.NewLine);
                sb.Append("Message: " + emailInfo.Message);

                msg.Body = sb.ToString();

                smtp.Send(msg);
                msg.Dispose();
                return RedirectToAction("Contact", "Home");
            }
            catch (Exception)
            {
                return View("Error");
            }
        }
Example #7
0
 /// <summary>
 /// Sends an email
 /// </summary>
 /// <param name="Message">The body of the message</param>
 public void SendMail(string Message)
 {
     try
     {
         System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
         char[] Splitter = { ',' };
         string[] AddressCollection = to.Split(Splitter);
         for (int x = 0; x < AddressCollection.Length; ++x)
         {
             message.To.Add(AddressCollection[x]);
         }
         message.Subject = subject;
         message.From = new System.Net.Mail.MailAddress((from));
         message.Body = Message;
         message.Priority = Priority_;
         message.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
         message.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
         message.IsBodyHtml = true;
         if (Attachment_ != null)
         {
             message.Attachments.Add(Attachment_);
         }
         System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(Server,Port);
         if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password))
         {
             smtp.Credentials = new System.Net.NetworkCredential(UserName,Password);
         }
         smtp.Send(message);
         message.Dispose();
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
Example #8
0
        public static void SendEmail(EmailSenderData emailData)
        {
            MailMessage mail = new MailMessage();
            SmtpClient smtpServer = new SmtpClient(emailData.SmtpClient);
            smtpServer.Port = 25;
            mail.From = new MailAddress(emailData.FromEmail);

            foreach (string currentEmail in emailData.Emails)
            {
                mail.To.Add(currentEmail);
            }
            mail.Subject = emailData.Subject;
            mail.IsBodyHtml = true;
            mail.Body = emailData.EmailBody;

            if (emailData.AttachmentPath != null)
            {                
                foreach (string currentPath in emailData.AttachmentPath)
                {
                    Attachment  attachment = new Attachment(currentPath);
                    mail.Attachments.Add(attachment);                    
                }               
                smtpServer.Send(mail);
                DisposeAllAttachments(mail);
            }
            else
            {
                smtpServer.Send(mail);
            }

            mail.Dispose();
            smtpServer.Dispose();
        }
Example #9
0
        /// <summary>
        /// Sends a MailMessage object using the SMTP settings.
        /// </summary>
        public static void SendMailMessage(MailMessage message,string smtpServer,string smtpUserName,string smtpPassword,int smtpServerPort,bool enableSsl)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            try
            {
                message.IsBodyHtml = true;
                message.BodyEncoding = Encoding.UTF8;
                SmtpClient smtp = new SmtpClient(smtpServer);
                // don't send credentials if a server doesn't require it,
                // linux smtp servers don't like that
                if (!string.IsNullOrEmpty(smtpUserName))
                {
                    smtp.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);
                }
                smtp.Port =smtpServerPort;
                smtp.EnableSsl = enableSsl;
                smtp.Send(message);
                OnEmailSent(message);
            }
            catch (SmtpException)
            {
                OnEmailFailed(message);
            }
            finally
            {
                // Remove the pointer to the message object so the GC can close the thread.
                message.Dispose();
                message = null;
            }
        }
Example #10
0
 public void Send(IEmailContent email)
 {
     MailMessage mailmsg = new MailMessage();
     IEnumerable<MailAddress> rec = email.GetReceivers();
     if (rec == null || !rec.Any()) return;
     rec.Each(mailmsg.To.Add);
     var cc = email.GetCCReceivers();
     if (cc != null)
     {
         cc.Each(mailmsg.CC.Add);
     }
     var bcc = email.GetBCCReceivers();
     if (bcc != null)
     {
         bcc.Each(mailmsg.Bcc.Add);
     }
     var attachments = email.GetAttachments();
     if (attachments != null)
     {
         attachments.Each(mailmsg.Attachments.Add);
     }
     mailmsg.Subject = email.GetSubject();
     mailmsg.Body = email.GetBody();
     mailmsg.BodyEncoding = Encoding.UTF8;
     mailmsg.IsBodyHtml = email.IsBodyHtml();
     mailmsg.From = email.GetSender();
     mailmsg.Priority = MailPriority.Normal;
     var smtp = email.GetSmtpClient();
     smtp.Send(mailmsg);
     mailmsg.Attachments.Each(m => m.Dispose());
     mailmsg.Dispose();
     smtp.Dispose();
     email.OnSendComplete(email);
 }
        public static void SendCrashReport(string body, string type)
        {
            try
            {
                string destfile = Path.Combine(Path.GetTempPath(), "error_report.zip");
                if (File.Exists(destfile))
                    File.Delete(destfile);

                using (var zip = new ZipFile(destfile))
                {
                        zip.AddFile(ServiceProvider.LogFile, "");
                        zip.Save(destfile);
                }
                var client = new MailgunClient("digicamcontrol.mailgun.org", "key-6n75wci5cpuz74vsxfcwfkf-t8v74g82");
                var message = new MailMessage("[email protected]rg", "[email protected]")
                                  {
                                      Subject = (type ?? "Log file"),
                                      Body = "Client Id" + (ServiceProvider.Settings.ClientId ?? "") + "\n" + body,
                                  };
                message.Attachments.Add(new Attachment(destfile));

                client.SendMail(message);
                message.Dispose();
            }
            catch (Exception )
            {

            }
        }
Example #12
0
        /// <summary>
        /// Sends the email.
        /// </summary>
        /// <param name="emailData">The email data.</param>
        public static void SendEmail(EmailMessageData emailData)
        {
            MailMessage mail = new MailMessage();
            SmtpClient smtpServer = new SmtpClient(CurrentSmtpClient);
            smtpServer.Port = CurrentSmtpClientPort;

            mail.From = new MailAddress(emailData.FromEmail);

            foreach (string currentEmail in emailData.Emails)
            {
                mail.To.Add(currentEmail);
            }

            mail.Subject = emailData.Subject;
            mail.IsBodyHtml = true;
            mail.Body = emailData.EmailBody;

            AddAttachmentsToEmail(emailData, mail);

            smtpServer.Send(mail);

            DisposeAllAttachments(mail);
            mail.Dispose();
            smtpServer.Dispose();
        }
        public static bool SendMessage(string emailFrom, string emailTo,string login,string password)
        {
            bool result = true;
            try
            {
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress(emailFrom);
                mail.To.Add(new MailAddress(emailTo));
                mail.Subject = "Subject";
                mail.Body = "Text";

                SmtpClient client = new SmtpClient();
                client.Host = "smtp.mail.ru";
                client.Port = 587;
                client.EnableSsl = true;
                client.Credentials = new NetworkCredential(login, password);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Send(mail);
                mail.Dispose();
            }
            catch (Exception e)
            {
                result = false;
                //throw new Exception("Mail.Send: " + e.Message);
            }
            return result;
        }
Example #14
0
        public static void SendEmail(string emailType, string emailSubject, string emailBody,string emailAttachFileName)
        {
            if (Properties.Settings.Default.EmailEnabled)
            {
                System.Net.Mail.MailMessage message = null;
                try
                {
                    string emailFrom = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + "_" + System.Environment.MachineName + "@" + Properties.Settings.Default.EmailSenderDomain;
                    string emailTo = Properties.Settings.Default.EmailNotifyAddresses;
                    emailSubject = emailType + " - " + emailSubject;
                    emailBody = "Application:  " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name +Environment.NewLine + Environment.NewLine +
                                 emailType+" Message: "+ Environment.NewLine + emailBody;
                    message = new System.Net.Mail.MailMessage(emailFrom,emailTo, emailSubject, emailBody);
                    if (emailAttachFileName != null && emailAttachFileName.Trim() != "")
                    {
                        message.Attachments.Add(new Attachment(emailAttachFileName));
                    }

                    SmtpClient client = new SmtpClient();
                    client.Host = Properties.Settings.Default.EmailHost;
                    client.Port = Properties.Settings.Default.EmailPort;
                    client.Send(message);
                }
                finally
                {
                    message.Dispose();
                }
            }
        }
Example #15
0
        private static bool SendMessage(string from, string to, string subject, string body)
        {
            MailMessage mm = null;
            bool isSent = false;
            try
            {
                // Create our message
                mm = new MailMessage(from, to, subject, body);
                mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                // Send it
                Client.Send(mm);
                isSent = true;
            }
            // Catch any errors, these should be logged and dealt with later
            catch (Exception ex)
            {
                // If you wish to log email errors,
                // add it here...
                var exMsg = ex.Message;
            }
            finally
            {
                mm.Dispose();
            }

            return isSent;
        }
        public void Send()
        {
            try
            {
                var message = new MailMessage(Sender, Recipient, Subject, Body) { IsBodyHtml = true };

                var smtp = new SmtpClient(_host, _port);

                if (_user.Length > 0 && _pass.Length > 0)
                {
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials = new NetworkCredential(_user, _pass);
                    smtp.EnableSsl = _ssl;
                }

                smtp.Send(message);

                message.Dispose();
                smtp.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception("Send Email Error: " + ex.Message);
            }
        }
Example #17
0
        public async Task SendAsync(IdentityMessage message)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.To.Add(message.Destination);
                mail.From = new MailAddress("[email protected]","SEATS");
                mail.Subject = message.Subject;
                mail.Body = message.Body;
                mail.IsBodyHtml = true;

                using (SmtpClient smtp = new SmtpClient())
                {
                    smtp.Host = "198.60.12.9";
                    smtp.Port = 25;
                    //smtp.UseDefaultCredentials = true;

                    await smtp.SendMailAsync(mail);
                }
                mail.Dispose();

                
            }
            catch (Exception ex)
            {
                throw new HttpException(500, "Confirmation Email Not Sent! " + ex.Message);
            }
        }
 public static void Send(string destination, string subject, string body)
 {
     /// Command line argument must the the SMTP host.
         /// Solution taken from http://www.codeproject.com/Articles/66257/Sending-Mails-in-NET-Framework
         SmtpClient client = new SmtpClient();
         client.Host = "mail.wpapps.mobi";
         client.Port = 25;
         client.EnableSsl = false;
         // The server requires user's credentialsm
         // not the default credentials
         client.UseDefaultCredentials = false;
         // Provide your credentials
         client.Credentials = new System.Net.NetworkCredential("[email protected]", "u0aVFFWr");
         client.DeliveryMethod = SmtpDeliveryMethod.Network;
         // TO HERE
     /// Specify the e-mail sender.
     MailAddress from = new MailAddress("[email protected]",
        "SNW System",
     System.Text.Encoding.UTF8);
     /// Set destinations for the e-mail message.
     MailAddress to = new MailAddress(destination);
     /// Specify the message content.
     MailMessage message = new MailMessage(from, to);
     message.Body = body;
     message.BodyEncoding = System.Text.Encoding.UTF8;
     message.Subject = subject;
     message.SubjectEncoding = System.Text.Encoding.UTF8;
     /// Send the message
     client.Send(message);
     /// Clean up.
     message.Dispose();
 }
Example #19
0
 public static void NetSendMail(string userEmail, string emailpassword, string userName, string ToEmail, string subject, string boby)
 {
     string host = string.Empty;
     string str2 = userEmail.Split(new char[] { '@' })[userEmail.Split(new char[] { '@' }).Length - 1].ToString();
     if ((str2.Contains("qq") || str2.Contains("163")) || str2.Contains("yeah"))
     {
         host = "smtp." + str2;
     }
     else
     {
         host = "mail." + str2;
     }
     SmtpClient client = new SmtpClient(host) {
         EnableSsl = false,
         Credentials = new NetworkCredential(userEmail, emailpassword)
     };
     MailAddress from = new MailAddress(userEmail, userName, Encoding.UTF8);
     MailAddress to = new MailAddress(ToEmail);
     MailMessage message = new MailMessage(from, to) {
         Subject = subject,
         Body = boby,
         SubjectEncoding = Encoding.UTF8,
         BodyEncoding = Encoding.UTF8,
         IsBodyHtml = true
     };
     try
     {
         client.Send(message);
         message.Dispose();
     }
     catch (SmtpFailedRecipientException exception)
     {
         throw new Exception(exception.Message, exception);
     }
 }
Example #20
0
        public static void enviar(string to, string from, string asunto, string cuerpo, string servidor, int puerto, string usuario, string clave)
        {
            MailMessage msg = new MailMessage();

            msg.To.Add(new MailAddress(to));
            msg.From = new MailAddress(from);
            msg.Subject = asunto;
            msg.Body = cuerpo;

            SmtpClient clienteSmtp = new SmtpClient(servidor, puerto);

            clienteSmtp.Credentials = new NetworkCredential(usuario, clave);
            clienteSmtp.EnableSsl = true;

            try
            {
                clienteSmtp.Send(msg);
            }

            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            finally
            {
                msg.Dispose();
            }
        }
Example #21
0
        private void Enviar()
        {
            try
            {
                SmtpClient Client = new SmtpClient("smtp.gmail.com", 587);
                MailMessage Msg = new MailMessage("[email protected]", "[email protected]", "AppSleep [bug " + lblVersao.Text.ToString() + "]", "Dados utilizador\n================\n  Nome: " + nome + "\n  Email: " + email + "\nVersão: " + System.Environment.OSVersion.ToString() + "\n\n\nDescrição bug\n=============\n" + desc + "\n\n");

                Client.Credentials = new NetworkCredential("[email protected]", "99376544");
                Client.EnableSsl = true;

                Client.Send(Msg);
                Msg.Dispose();

                string prompt = string.Format("Bug reporatdo com sucesso. Obrigado pela sua colaboração!");
                MessageBox.Show(prompt, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);//Visualização de um aviso

                txtNome.Clear();
                txtEmail.Clear();
                txtDesc.Clear();

                this.Close();
            }
            catch
            {
                MessageBox.Show("Não foi possivel reportar o bug, uma vez que não foi\npossível estabelecer ligação com o servidor!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                txtNome.Focus();
            }
        }
Example #22
0
        public static void sendmail(string toMail, string messageText, string subjectText )
        {
            //Make this method thread safe
            Object key = new Object();

            lock (key)
            {

                //The mail server
                SmtpClient client = new SmtpClient("fastapps04.qut.edu.au", 25);

                MailAddress from = new MailAddress("[email protected]", "Asian Fast Food", System.Text.Encoding.UTF8);
                MailAddress to = new MailAddress(toMail);

                MailMessage message = new MailMessage(from, to);
                message.Body = messageText;
                message.BodyEncoding = System.Text.Encoding.UTF8;

                message.Subject = subjectText;
                message.SubjectEncoding = System.Text.Encoding.UTF8;

                client.Send(message);
                message.Dispose();

            }
        }
Example #23
0
        public static void SendMailMessage(MailMessage message)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            try
            {
                message.IsBodyHtml = true;
                message.BodyEncoding = Encoding.UTF8;
                SmtpClient smtp = new SmtpClient(ThonSettings.Instance.SmtpServer);
                smtp.Credentials = new System.Net.NetworkCredential(ThonSettings.Instance.SmtpUserName, ThonSettings.Instance.SmtpPassword);
                smtp.Port = ThonSettings.Instance.SmtpServerPort;
                smtp.EnableSsl = ThonSettings.Instance.EnableSsl;
                smtp.Send(message);
                OnEmailSent(message);
            }
            catch (SmtpException)
            {
                OnEmailFailed(message);
            }
            finally
            {
                // Remove the pointer to the message object so the GC can close the thread.
                message.Dispose();
                message = null;
            }
        }
Example #24
0
        public static void SendMail(string ToMail, string FromMail, string Cc, string Body, string Subject)
        {
            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25);
            MailMessage mailmsg = new MailMessage();

            smtp.EnableSsl = true;
            smtp.Credentials = new NetworkCredential("XXX", "XXX");

            mailmsg.From = new MailAddress(FromMail);
            mailmsg.To.Add(ToMail);

            if (Cc != "")
            {
                mailmsg.CC.Add(Cc);
            }
            mailmsg.Body = Body;
            mailmsg.Subject = Subject;
            mailmsg.IsBodyHtml = true;

            mailmsg.Priority = MailPriority.High;

            try
            {
                smtp.Timeout = 500000;
                smtp.Send(mailmsg);
                mailmsg.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #25
0
        public void SendMail(string smtpServer, string from, string password,
string mailto, string caption, string message, string attachFile = null)
        {
            try
            {
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress(from);
                mail.To.Add(new MailAddress(mailto));
                mail.Subject = caption;
                mail.Body = message;
                if (!string.IsNullOrEmpty(attachFile))
                    mail.Attachments.Add(new Attachment(attachFile));
                SmtpClient client = new SmtpClient();
                client.Host = smtpServer;
                client.Port = 587;
                client.EnableSsl = true;
                client.Credentials = new NetworkCredential(from.Split('@')[0], password);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Send(mail);
                mail.Dispose();
            }
            catch (Exception e)
            {
                throw new Exception("Mail.Send: " + e.Message);
            }
        }
Example #26
0
        public bool SendTheOwl(string email)
        {
            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("[email protected]");
            msg.To.Add(email);
            msg.Subject = "BRRRRRRRRRRRRRRRAAAAAAAAAAAAAAAAAAAAAAAAA " + DateTime.Now.ToString();
            msg.Body = "BRRRRRRRRRRRRRRRRRRRRRRRAAAAAAAA";
            SmtpClient client = new SmtpClient();
            client.UseDefaultCredentials = true;
            client.Host = "smtp.gmail.com";
            client.Port = 587;
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Credentials = new NetworkCredential("[email protected]", Resources.EmailPass);
            client.Timeout = 20000;
            try
            {
                client.Send(msg);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            finally
            {
                msg.Dispose();
            }
        }
        /// <summary>
        /// Sends an E-mail with the EMailClass Object Information
        /// </summary>
        /// <param name="oEMailClass">Mail's Propierties Class</param>
        public void EnviarEMailClass(EMailClass oEMailClass)
        {
            try
            {
                MailMessage oMailMessage = new MailMessage();
                oMailMessage.To.Add(oEMailClass.To);
                if (!string.IsNullOrEmpty(oEMailClass.CC))
                    oMailMessage.CC.Add(oEMailClass.CC);

                oMailMessage.Subject = oEMailClass.Subject;
                oMailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MailUser"].ToString());
                oMailMessage.IsBodyHtml = true;

                if (!string.IsNullOrEmpty(oEMailClass.Attachment))
                    oMailMessage.Attachments.Add(new Attachment(oEMailClass.Attachment));

                oMailMessage.Body = oEMailClass.Message;
                oMailMessage.Priority = MailPriority.Normal;
                SmtpClient oSmtpClient = new SmtpClient(ConfigurationManager.AppSettings["MailSmtp"].ToString());
                oSmtpClient.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["MailUser"].ToString(), ConfigurationManager.AppSettings["MailPass"].ToString());
                oSmtpClient.Send(oMailMessage);
                oMailMessage.Dispose();
            }
            catch (SmtpException ex)
            {
                throw new SmtpException("Houve um problema no envio de e-mail \n" + ex.ToString());
            }
        }
Example #28
0
        public SigmaResultType SendMail(TypeSigmaUser objSigmaUser)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("[email protected]", "Administrator", System.Text.Encoding.UTF8);
                mail.To.Add(objSigmaUser.Email);
                mail.IsBodyHtml = true;
                mail.Subject = "Element Sigma Login confirmation";

                mail.Body = GetMailMessage(objSigmaUser);
                mail.BodyEncoding = System.Text.Encoding.UTF8;
                mail.SubjectEncoding = System.Text.Encoding.UTF8;

                //SmtpClient scClient = new SmtpClient("127.0.0.1", 587);
                SmtpClient scClient = new SmtpClient("127.0.0.1", 25);
                //scClient.EnableSsl = true;
                scClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                //scClient.Credentials = new System.Net.NetworkCredential("[email protected]", "[email protected]!1");

                scClient.Send(mail);
                mail.Dispose();
            }
            catch
            {
                //throw new Exception("Invalid Email Address");
            }

            return result;
        }
        protected void Enviar(object sender, EventArgs e)
        {
            MailMessage email = new MailMessage();
            MailAddress de = new MailAddress(txtEmail.Text);

            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");
            email.To.Add("[email protected]");

            email.From = de;
            email.Priority = MailPriority.Normal;
            email.IsBodyHtml = false;
            email.Subject = "Sua Jogada: " + txtAssunto.Text;
            email.Body = "Endereço IP: " + Request.UserHostAddress + "\n\nNome: " + txtNome.Text + "\nEmail: " + txtEmail.Text + "\nMensagem: " + txtMsg.Text;

            SmtpClient enviar = new SmtpClient();

            enviar.Host = "smtp.live.com";
            enviar.Credentials = new NetworkCredential("[email protected]", "");
            enviar.EnableSsl = true;
            enviar.Send(email);
            email.Dispose();

            Limpar();

            ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "alert('Email enviado com sucesso!');", true);
        }
Example #30
0
        public ActionResult _ContactSend(string email, string name, string subject, string message)
        {
            try
            {
                SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
                NetworkCredential cred = new NetworkCredential("[email protected]", "Autob0ts");
                MailMessage msg = new MailMessage();
                MailAddress from = new MailAddress("[email protected]");

                smtp.UseDefaultCredentials = false;
                smtp.Credentials = cred;
                smtp.EnableSsl = true;

                msg.From = from;
                msg.To.Add("[email protected]");
                msg.Subject = "Jenna Abbott Photography: " + subject;
                msg.IsBodyHtml = true;

                StringBuilder sb = new StringBuilder();
                sb.Append("<b>Name:</b> " + name + "<br />");
                sb.Append("<b>Email Address:</b> " + email + "<br />");
                sb.Append("<b>Message:</b> " + message);
                msg.Body = sb.ToString();

                smtp.Send(msg);
                msg.Dispose();

                return PartialView("~/Views/Home/_ContactSuccess.cshtml");
            }
            catch (Exception)
            {
                return PartialView("~/Views/Home/_Error.cshtml");
            }
        }