当前位置: 首页>>代码示例>>C#>>正文


C# System.Net.Mail.SmtpClient.SendMailAsync方法代码示例

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


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

示例1: SendAsync

        public Task SendAsync(IdentityMessage message)
        {
            // Credentials:
            var credentialUserName = ConfigurationManager.AppSettings["CredentialUserName"];
            var sentFrom = ConfigurationManager.AppSettings["SentFrom"];
            var pwd = ConfigurationManager.AppSettings["EmailPassword"];

            // 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;
            mail.IsBodyHtml = true;

            // Send:
            return client.SendMailAsync(mail);
        }
开发者ID:almarkua,项目名称:TimeManager,代码行数:33,代码来源:EmailService.cs

示例2: 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

示例3: SendAsync

        public static Task SendAsync(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:
            return client.SendMailAsync(mail);
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:27,代码来源:EmailClient.cs

示例4: 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

示例5: SendAsync

        public Task SendAsync(string destination, string subject, string body)
        {
            const string credentialUserName = "[email protected]";
            const string sentFrom = "[email protected]";
            const string pwd = "Itadakimas2014";

            var client =
                new System.Net.Mail.SmtpClient("smtp-mail.outlook.com")
                {
                    Port = 587,
                    DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false
                };

            var credentials =
                new NetworkCredential(credentialUserName, pwd);

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

            var mail =
                new System.Net.Mail.MailMessage(sentFrom, destination)
                {
                    Subject = subject,
                    Body = body
                };

            return client.SendMailAsync(mail);
        }
开发者ID:nuquernalach,项目名称:Forum,代码行数:29,代码来源:AccountController.cs


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