Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var emailMessage = new MailMessage();
- emailMessage.To.Add(new MailAddress(emailRecipicant,customerName.Trim()));
- emailMessage.From = new MailAddress(smtpEmail);
- emailMessage.Subject = $"{emailSubject}";
- emailMessage.Body = string.Format(body);
- emailMessage.IsBodyHtml = true;
- using (var smtp = new SmtpClient())
- {
- smtp.UseDefaultCredentials = false;
- var credential = new NetworkCredential
- {
- UserName = smtpUsername,
- Password = smtpPassword
- };
- smtp.Credentials = credential;
- smtp.Host = smtpHost;
- smtp.Port = Convert.ToInt32(smtpPort);
- smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
- //smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
- //smtp.PickupDirectoryLocation = "C:\Users\pht_000\Desktop\Customers\Email\PickUp\";
- smtp.EnableSsl = false;
- smtp.Send(emailMessage);
- }
- foreach (var recipicant in model.ToList())
- {
- string emailRecipicant = recipicant.Email;
- string emailSubject = recipicant.Subject;
- string message1 = recipicant.Message;
- string encryptedLink = recipicant.EncryptedEmail;
- string customerName = recipicant.Contact;
- SendEmail(emailRecipicant, emailSubject, message1, encryptedLink, customerName);
- counter++;
- }
Add Comment
Please, Sign In to add comment