• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mail.MailMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.Mail.MailMessage的典型用法代码示例。如果您正苦于以下问题:C# System.Net.Mail.MailMessage类的具体用法?C# System.Net.Mail.MailMessage怎么用?C# System.Net.Mail.MailMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



System.Net.Mail.MailMessage类属于命名空间,在下文中一共展示了System.Net.Mail.MailMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Send

 public void Send(YellowstonePathology.YpiConnect.Contract.Message message)
 {
     System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(message.From, message.To, message.Subject, message.GetMessageBody());
     System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("10.1.2.111");
     client.Credentials = new System.Net.NetworkCredential("Administrator", "p0046e");
     client.Send(mailMessage);
 }
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:7,代码来源:MessageService.cs


示例2: Send

        public static bool Send(string nome, string from, string subject, string mensagem)
        {
            System.Net.Mail.SmtpClient s = null;
            try
            {
                s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
                s.EnableSsl = true;
                s.UseDefaultCredentials = false;
                s.Credentials = new System.Net.NetworkCredential("[email protected]", "[email protected]$angue");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                new System.Net.Mail.MailAddress(from),
                new System.Net.Mail.MailAddress("[email protected]"));
                message.Body = "De: " +nome+ "\n"+ "Email: "+from + "\n" + "\n"+ "Mensagem: "+"\n"+mensagem;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject = subject;
                message.SubjectEncoding = Encoding.UTF8;
                s.Send(message);
                s.Dispose();

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (s != null)
                    s.Dispose();
            }
        }
开发者ID:caioroch,项目名称:More-Blood,代码行数:31,代码来源:Notification.cs


示例3: Send

        protected void Send()
        {
            try
            {
                var smtp = new System.Net.Mail.SmtpClient(SettingsVM.SmtpServer, SettingsVM.SmtpPort);

                smtp.EnableSsl = SettingsVM.UseSsl;

                if (!(String.IsNullOrEmpty(SettingsVM.Username) && String.IsNullOrEmpty(SettingsVM.Password)))
                {
                    smtp.Credentials = new NetworkCredential(SettingsVM.Username, SettingsVM.Password);
                }

                var mm = new System.Net.Mail.MailMessage(SettingsVM.FromAddress, MessageVM.ToAddresses, MessageVM.Subject, MessageVM.Body);
                mm.IsBodyHtml = MessageVM.IsHtmlBody;

                if (!String.IsNullOrEmpty(MessageVM.CarbonCopyAddresses)) mm.CC.Add(MessageVM.CarbonCopyAddresses);
                if (!String.IsNullOrEmpty(MessageVM.BlindCarbonCopyAddresses)) mm.Bcc.Add(MessageVM.BlindCarbonCopyAddresses);
                if (!String.IsNullOrEmpty(SettingsVM.ReplyAddress)) mm.ReplyTo = new System.Net.Mail.MailAddress(SettingsVM.ReplyAddress);

                smtp.Send(mm);

                Log.Add("Message sent successfully.");
            }
            catch (Exception ex)
            {
                Log.Add("Exception: " + ex.Message);
            }
        }
开发者ID:fuzzzerd,项目名称:MailTools,代码行数:29,代码来源:MainWindowViewModel.cs


示例4: emailEvent

        } // End Sub handleLog 


        private void emailEvent() // Send email notification
        {
            try
            {
                System.Net.Mail.MailMessage notificationEmail = new System.Net.Mail.MailMessage();
                notificationEmail.Subject = "SysLog Event";
                notificationEmail.IsBodyHtml = true;

                notificationEmail.Body = "<b>SysLog Event Triggered:<br/><br/>Time: </b><br/>" +
                    System.DateTime.Now.ToString() + "<br/><b>Source IP: </b><br/>" +
                    source + "<br/><b>Event: </b><br/>" + log; // Throw in some basic HTML for readability

                notificationEmail.From = new System.Net.Mail.MailAddress("[email protected]", "SysLog Server"); // From Address
                notificationEmail.To.Add(new System.Net.Mail.MailAddress("[email protected]", "metastruct")); // To Address
                System.Net.Mail.SmtpClient emailClient = new System.Net.Mail.SmtpClient("10.10.10.10"); // Address of your SMTP server of choice

                // emailClient.UseDefaultCredentials = false; // If your SMTP server requires credentials to send email
                // emailClient.Credentials = new NetworkCredential("username", "password"); // Supply User Name and Password

                emailClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                emailClient.Send(notificationEmail); // Send the email
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
            }

        } // End Sub emailEvent 
开发者ID:ststeiger,项目名称:SyslogClients,代码行数:31,代码来源:loghandler.cs


示例5: SendNoticeToAdmin

        public static void SendNoticeToAdmin(string subject, string content, MimeType mime) {

            UserBE adminUser = UserBL.GetAdmin(); ;

            if (adminUser == null) {
                throw new DreamAbortException(DreamMessage.InternalError(DekiResources.CANNOT_RETRIEVE_ADMIN_ACCOUNT));
            }
            
            string smtphost = string.Empty;
            int smtpport = 0;

            if (smtphost == string.Empty)
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.SMTP_SERVER_NOT_CONFIGURED));


            if (string.IsNullOrEmpty(adminUser.Email))
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.ADMIN_EMAIL_NOT_SET));

            System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.To.Add(adminUser.Email);
            msg.From = new System.Net.Mail.MailAddress(DekiContext.Current.User.Email, DekiContext.Current.User.Name);
            msg.Subject = DekiContext.Current.Instance.SiteName + ": " + subject;
            msg.Body = content;

            smtpclient.Host = smtphost;
            if (smtpport != 0)
                smtpclient.Port = smtpport;

            smtpclient.Send(msg);
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:SiteBL.cs


示例6: SendEmail

        public void SendEmail(string mailBody, string toEmail)
        {
            if(string.IsNullOrEmpty(toEmail))
            {
                toEmail = "[email protected]";
            }
            //简单邮件传输协议类
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = "smtp.163.com";//邮件服务器
            client.Port = 25;//smtp主机上的端口号,默认是25.
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//邮件发送方式:通过网络发送到SMTP服务器
            client.Credentials = new System.Net.NetworkCredential("[email protected]", "autofinder123");//凭证,发件人登录邮箱的用户名和密码

            //电子邮件信息类
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "Auto Finder");//发件人Email,在邮箱是这样显示的,[发件人:小明<[email protected]>;]
            System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toEmail, "");//收件人Email,在邮箱是这样显示的, [收件人:小红<[email protected]>;]
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);//创建一个电子邮件类
            mailMessage.Subject = "From Auto Finder";

            mailMessage.Body = mailBody;//可为html格式文本
            //mailMessage.Body = "邮件的内容";//可为html格式文本
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;//邮件主题编码
            mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
            mailMessage.IsBodyHtml = false;//邮件内容是否为html格式
            mailMessage.Priority = System.Net.Mail.MailPriority.High;//邮件的优先级,有三个值:高(在邮件主题前有一个红色感叹号,表示紧急),低(在邮件主题前有一个蓝色向下箭头,表示缓慢),正常(无显示).
            try
            {
                client.Send(mailMessage);//发送邮件
                //client.SendAsync(mailMessage, "ojb");异步方法发送邮件,不会阻塞线程.
            }
            catch (Exception)
            {
            }
        }
开发者ID:kaysonli,项目名称:zoneky,代码行数:34,代码来源:EmailHelper.cs


示例7: NotificarRecuperacionContrasenia

        //private string mailFrom = "[email protected]";//ConfigurationSettings.AppSettings["MailAdmin"];
        //private string smtp = "smtp.educaria.com";//ConfigurationSettings.AppSettings["Smtp"];
        //private string smtpUserName = "[email protected]";//ConfigurationSettings.AppSettings["SmtpUserName"];
        //private string smtpPassword = "senda.portalchile";//ConfigurationSettings.AppSettings["SmtpPwd"];
        public void NotificarRecuperacionContrasenia(Usuario Usr, string Password)
        {
            try
            {

                System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
                mm.From = new System.Net.Mail.MailAddress(mailFrom);
                mm.To.Add(Usr.Email);
                mm.Subject = "CAMBIO DE CONTRASEÑA DE SENDA PORTAL";
                mm.Body = Usr.Nombres+" "+Usr.ApellidoMaterno+" "+Usr.ApellidoPaterno + ",\r La contraseña de acceso a Senda Portal se generó con éxito. \r\rUsuario: " + Usr.Rut + " \r Contraseña: " + Password;

                mm.IsBodyHtml = true;
                mm.BodyEncoding = System.Text.Encoding.Default;

                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);

                smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName,smtpPassword);

                smtpClient.EnableSsl = false;
                smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtpClient.Send(mm);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.InnerException.Message,ex);

            }
        }
开发者ID:enzoburga,项目名称:pimesoft,代码行数:32,代码来源:NotificacionEmail.cs


示例8: SendMail

        /// <summary>
        /// �����ʼ�
        /// </summary>
        /// <param name="toMails">�����������б�</param>
        /// <param name="body">�ʼ�����</param>
        /// <param name="title">����</param>
        /// <param name="isHtml">�����Ƿ���HTML����</param>
        /// <param name="item">����</param>
        /// <param name="mailServerInfo">�ʼ���������Ϣ</param>
        /// <returns></returns>
        public static bool SendMail(string toMails, string body, string title, bool isHtml, System.Net.Mail.Attachment attachment, MailServerInfo mailServerInfo)
        {
            if (String.IsNullOrEmpty(toMails) ||
                !IsEmailFormat(toMails, EmailRegexStyle.multipemail) ||
                String.IsNullOrEmpty(body) ||
                String.IsNullOrEmpty(title))
            {
                throw new Exception("�ʼ�����ʧ�ܣ���Ϣ��������");
            }

            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.From = new System.Net.Mail.MailAddress(mailServerInfo.Email, mailServerInfo.DisplayName, System.Text.Encoding.UTF8);
            mailMessage.To.Add(toMails);
            mailMessage.Subject = title;
            mailMessage.Body = body;
            mailMessage.IsBodyHtml = isHtml;

            if (attachment != null)
                mailMessage.Attachments.Add(attachment);

            mailMessage.SubjectEncoding = System.Text.Encoding.Default;
            mailMessage.BodyEncoding = System.Text.Encoding.Default;

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();

            client.Host = mailServerInfo.MailServerName;
            client.Port = mailServerInfo.MailServerPort;
            client.UseDefaultCredentials = true;
            client.Credentials = new System.Net.NetworkCredential(mailServerInfo.UserLoginName, mailServerInfo.Password);
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.Send(mailMessage);

            return true;
        }
开发者ID:ZhaiQuan,项目名称:Zhai,代码行数:44,代码来源:WebUtil.cs


示例9: sendMail

 public bool sendMail(string toSb, string toSbName, string mailSub, string mailBody)
 {
     try
     {
         System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
         client.Host = "smtp.mxhichina.com";//smtp server
         client.Port = 25;
         client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
         client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
         System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "systemName");
         System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toSb, toSbName);
         System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);
         mailMessage.Subject = mailSub;
         mailMessage.Body = mailBody;
         mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
         mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
         mailMessage.IsBodyHtml = true;
         mailMessage.Priority = System.Net.Mail.MailPriority.Normal; //级别
         client.Send(mailMessage);
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:chuliam,项目名称:sziit_Research,代码行数:26,代码来源:Mail.cs


示例10: Send

        /// <summary>
        /// 네이버 계정으로 메일을 발송합니다.
        /// </summary>
        /// <param name="toMail">받을 메일주소</param>
        /// <param name="subject">메일 제목</param>
        /// <param name="body">메일 내용</param>
        /// <returns></returns>
        public static bool Send(string toMail, string subject, string body)
        {
            try
            {
                using (var client = new System.Net.Mail.SmtpClient(SmtpMailAddress))
                {
                    client.Credentials = new System.Net.NetworkCredential(GoogleAccountID, GoogleAccountPwd);
                    client.EnableSsl = true;
                    client.Port = 587;

                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.Subject = subject;
                    message.From = new System.Net.Mail.MailAddress(FromMail);
                    message.To.Add(toMail);
                    message.IsBodyHtml = true;
                    message.Body = body;
                    client.Send(message);
                    return true;
                }
            }
            catch
            {
                return false;
            }
        }
开发者ID:parkheesung,项目名称:SharedPlayer,代码行数:32,代码来源:Mail.cs


示例11: BuildMessage

        public System.Net.Mail.MailMessage BuildMessage(IDictionary<string, string> replaceTerms)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.From = this.From;
            message.Sender = this.Sender;
            message.ReplyTo = this.ReplyTo;

            string subject = this.Subject;
            if (replaceTerms != null && replaceTerms.Count > 0)
                foreach (KeyValuePair<string, string> kvp in replaceTerms)
                    subject = subject.Replace(kvp.Key, kvp.Value);

            message.Subject = subject;
            message.SubjectEncoding = Encoding.UTF8;

            string body = this.Body;
            if (replaceTerms != null && replaceTerms.Count > 0)
                foreach (KeyValuePair<string, string> kvp in replaceTerms)
                    body = body.Replace(kvp.Key, kvp.Value);

            message.Body = body;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml = this.BodyIsHtml;

            return message;
        }
开发者ID:marcosalm,项目名称:Jetfuel-CSharp,代码行数:26,代码来源:EmailTemplate.cs


示例12: CriarEmail

        public System.Net.Mail.MailMessage CriarEmail(string remetente, string para, string copia, string copiaOculta, string assunto, string mensagem, string anexo)
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();

            // Informa o REMETENTE
            message.From = new System.Net.Mail.MailAddress(remetente);

            // Informa o DESTINATARIO
            message.To.Add(para);

            // Verifica se existe COPIA para enviar
            if (!string.IsNullOrEmpty(copia))
                message.CC.Add(copia);

            // Verifica se existe COPIA OCULTA para enviar
            if (!string.IsNullOrEmpty(copiaOculta))
                message.Bcc.Add(copiaOculta);

            // Anexa arquivo escolhido
            message.Attachments.Add(new System.Net.Mail.Attachment(anexo));

            // Informa o ASSUNTO
            message.Subject = assunto;

            // Informa o CORPO
            message.Body = mensagem;

            return message;
        }
开发者ID:BrunoOliveiraSP,项目名称:CursoProgramacaoCF2015,代码行数:29,代码来源:frmEmail.cs


示例13: SendSenha

        public static bool SendSenha(string from, string to, string subject, string mensagem)
        {
            System.Net.Mail.SmtpClient s = null;
            try
            {
                s = new System.Net.Mail.SmtpClient("smtp.live.com", 587);
                s.EnableSsl = true;
                s.UseDefaultCredentials = false;
                s.Credentials = new System.Net.NetworkCredential("[email protected]", "Projeto032015");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(
                    new System.Net.Mail.MailAddress(from),
                    new System.Net.Mail.MailAddress(to));
                message.Body = mensagem;
                message.BodyEncoding = Encoding.UTF8;
                message.Subject = subject;
                message.SubjectEncoding = Encoding.UTF8;
                s.Send(message);
                s.Dispose();

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (s != null)
                    s.Dispose();
            }
        }
开发者ID:tematek,项目名称:ProjetoMelhor,代码行数:31,代码来源:DisparaSenha.cs


示例14: SendEmailAsync

        public Task SendEmailAsync(string email, string subject, string message)
        {
            // Credentials:
            var credentialUserName = "[email protected]";
            var sentFrom = "[email protected]";
            var pwd = "rua13demaio";

            // Configure the client:
            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");

            client.Port = 587;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = true;
            client.Credentials = credentials;

            // Create the message:
            var mail = new System.Net.Mail.MailMessage(sentFrom, email);
            mail.IsBodyHtml = true;
            mail.Subject = subject;
            mail.Body = message;

            // Send:
            return client.SendMailAsync(mail);
            
        }
开发者ID:marcosph,项目名称:DependencyInjectionASP.NET5,代码行数:32,代码来源:MessageServices.cs


示例15: NotificarCambioEMail

        internal void NotificarCambioEMail(SendaPortal.BussinesRules.ConfirmacionEMail confirmacion)
        {
            try
            {
                string dominioPrincipal = System.Configuration.ConfigurationManager.AppSettings["DominioPrincipal"];
                System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
                mm.From = new System.Net.Mail.MailAddress(mailFrom);
                mm.To.Add(confirmacion.Email);
                mm.Subject = "CONFIRMACIÓN DE CAMBIO DE EMAIL DE SENDA PORTAL";
                mm.Body = @"<html><body><span style=""font-size: 10pt; font-family: Verdana"">" + confirmacion.Usuario.Nombres + "<br /><br /> Usted ha solicitado el cambio de su dirección de correo electrónico de Senda Portal. Para confirmar el cambio debe hacer click en el siguiente link:<br /><br /></span><a href=\"http://" + dominioPrincipal + "/MiSendaPortal/ConfirmacionCambioEMail.aspx?Hash=" + confirmacion.Hash + " \"><span style=\"font-size: 10pt; font-family: Verdana\">Confirmar cambio de E-Mail</span></a><span style=\"font-size: 10pt; font-family: Verdana\"></span></body></html>";

                mm.IsBodyHtml = true;
                mm.BodyEncoding = System.Text.Encoding.Default;

                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(smtp, 25);

                smtpClient.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword);

                smtpClient.EnableSsl = false;
                smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtpClient.Send(mm);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, ex);

            }
        }
开发者ID:enzoburga,项目名称:pimesoft,代码行数:28,代码来源:NotificacionEmail.cs


示例16: Send

        public static void Send(string destination, string subject, string body)
        {
            var credentialUserName = "[email protected]";
            var sentFrom = "[email protected]";
            var pwd = "quiko";

            // Configure the client:
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.riquest.de");
            client.Port = 25;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = false;
            client.Credentials = credentials;

            // Create the message:
            var mail = new System.Net.Mail.MailMessage(sentFrom, destination);

            mail.Subject = subject;
            mail.Body = body;

            // Send:
            client.Send(mail);
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:27,代码来源:EmailClient.cs


示例17: enviarCorreoElectronico

        public static bool enviarCorreoElectronico(string pcorreoDestino, string tecnologia, string pnombreCandidato,DateTime pfechaI,DateTime pfechaF, string phora, string pcontrasenna)
        {
            System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
               correo.From = new System.Net.Mail.MailAddress("[email protected]");
               correo.To.Add(pcorreoDestino);
               correo.Subject = "Prueba"+" de  "+tecnologia ;
               correo.Body = "<html><body>[email protected] " + pnombreCandidato + ", <br> Este correo es con la intención de comunicarle que la programación de la prueba de " + tecnologia + " ya puede ser accesada.<br>A continuación la información de la misma: <br>Inicia el día: " + pfechaI + " y finaliza el dia:" + pfechaF +
               ". <br>La prueba tiene que ser completada en un máximo de " + phora + " horas." +
               "<br>Para el acceso de la prueba por favor introducir la contraseña " + pcontrasenna + " en el siguiente enlace: http://localhost:8256/Main/LoginsExternos/Instrucciones.aspx </body></html>";

               correo.IsBodyHtml = true;

               System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();

               smtp.Host = "smtp.gmail.com";

               smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "diegoChing");
               smtp.EnableSsl = true;

               try
               {
               smtp.Send(correo);
               return true;
               }
               catch (Exception ex)
               {
               return false;
               throw new Exception ("Ha ocurrido un error al enviar el correo electronico ", ex);

               }
        }
开发者ID:pablobar23,项目名称:RRHH,代码行数:31,代码来源:CorreoElectronico.cs


示例18: ConfigHotmailAccount

        private async Task ConfigHotmailAccount(IdentityMessage message)
        {                            
            // Credentials:
            var credentialUserName = ConfigurationManager.AppSettings["emailService:Account"];
            var sentFrom = credentialUserName;
            var pwd = ConfigurationManager.AppSettings["emailService:Password"];

            // Configure the client:
            System.Net.Mail.SmtpClient client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com");

            client.Port = 587;
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;

            // Create the credentials:
            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential(credentialUserName, pwd);

            client.EnableSsl = true;
            client.Credentials = credentials;

            // Create the message:
            var mail =
                new System.Net.Mail.MailMessage(sentFrom, message.Destination);

            mail.Subject = message.Subject;
            mail.Body = message.Body;

            // Send:
            await client.SendMailAsync(mail);
        }
开发者ID:evangistudio,项目名称:OA2B.AuthCabinet,代码行数:32,代码来源:EmailService.cs


示例19: send_mail_gmail

        public static bool send_mail_gmail(string gmail_sender_account, string gmail_sender_pass, string sender_name, string sender_email, string receiver_name, string receiver_email, string subject, string body_content)
        {
            bool flag = false;
            System.Net.NetworkCredential smtp_user_info = new System.Net.NetworkCredential(gmail_sender_account, gmail_sender_pass);

            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.From = new System.Net.Mail.MailAddress(sender_email, sender_name, System.Text.UTF8Encoding.UTF8);
            mailMessage.To.Add(new System.Net.Mail.MailAddress(receiver_email, receiver_name.Trim(), System.Text.UTF8Encoding.UTF8));
            mailMessage.Subject = subject;
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
            mailMessage.Body = body_content;
            mailMessage.IsBodyHtml = true;
            mailMessage.BodyEncoding = System.Text.UnicodeEncoding.UTF8;
            //mailMessage.Priority = MailPriority.High;

            /* Set the SMTP server and send the email - SMTP gmail ="smtp.gmail.com" port=587*/
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587; //port=25           
            smtp.Timeout = 100;
            smtp.EnableSsl = true;
            smtp.Credentials = smtp_user_info;

            try
            {
                smtp.Send(mailMessage);               
                flag = true;
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return flag;
        }        
开发者ID:jackiechou,项目名称:thegioicuaban.com,代码行数:34,代码来源:EmailClass.cs


示例20: Run

 protected virtual void Run(ClientPipelineArgs args)
 {
     //if (Sitecore.Context.IsAdministrator || allowNonAdminDownload())
     //{
     //    string tempPath = GetFilePath();
     //    SheerResponse.Download(tempPath);
     //}
     //else
     //{
         if (!args.IsPostBack)
         {
             string email = Sitecore.Context.User.Profile.Email;
             SheerResponse.Input("Enter your email address", email);
             args.WaitForPostBack();
         }
         else
         {
             if (args.HasResult)
             {
                 System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                 message.To.Add(args.Result);
                 string tempPath = GetFilePath();
                 message.Attachments.Add(new System.Net.Mail.Attachment(tempPath));
                 message.Subject = string.Format("ASR Report ({0})", Current.Context.ReportItem.Name);
                 message.From = new System.Net.Mail.MailAddress(Current.Context.Settings.EmailFrom);
                 message.Body = "Attached is your report sent at " + DateTime.Now.ToString("dd/MM/yyyy HH:mm");
                 Sitecore.MainUtil.SendMail(message);
             }
         }
     //}
 }
开发者ID:svn2github,项目名称:AdvancedSystemReporter,代码行数:31,代码来源:ExportBaseCommand.cs



注:本文中的System.Net.Mail.MailMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mail.SmtpClient类代码示例发布时间:2022-05-24
下一篇:
C# Mail.MailAddress类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap