Exemplo n.º 1
0
 protected void TestSendEmail()
 {
     try
     {
         System.Text.StringBuilder strBody = new System.Text.StringBuilder();//邮件内容
         strBody.Append("点击下面链接激活账号,8848小时生效,否则重新注册账号,链接只能使用一次,请尽快激活!");
         strBody.Append("点击这里");
         strBody.Append("如未能激活请点击下面链接:http://localhost:38216/Validate.aspx?Account=&ValidateCode=" + Decryption.Encrypt("2") + "");
         string attachPath = @"H:/新建文件夹/demo.txt";
         //qfahmjmzxheobaih
         Email email = new Email("smtp.qq.com", "*****@*****.**", "*****@*****.**", "邮箱验证", strBody.ToString(), "467457110", "qxtrjmpotwrzcajb", "587", true, true);
         email.AddAttachments(attachPath);
         email.Send();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        private async Task <Email> ProcessEmailResponseAsync(EmailResponse response)
        {
            if (response is null)
            {
                throw new ArgumentNullException(nameof(response));
            }

            var email = new Email
            {
                Text    = response.Text,
                Html    = response.Html,
                Subject = response.Subject,
            };

            email.AddSenders(response.From);
            email.AddRecipients(response.To);
            email.AddAttachments(await ExtractAttachmentsMetadataAsync(response).ConfigureAwait(false));

            return(email);
        }