Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool SendEmail(string password, string from, string to, string cc, string subject, string[] attachedFiles, string body, string host, int port)
- {
- try
- {
- MailMessage mail = new MailMessage(from, to);
- //foreach (var attachedFile in attachedFiles)
- //{
- // mail.Attachments.Add(new Attachment(attachedFile.ToString()));
- //}
- mail.Attachments.Add(new Attachment(@"C:UsersliakaDesktopJordanFileMailerFileMailerBacklog_07_12_2018.xlsx"));
- mail.Attachments.Add(new Attachment(@"C:UsersliakaDesktopJordanFileMailerFileMailertest.txt"));
- mail.Subject = subject;
- mail.Body = body;
- mail.CC.Add(cc);
- var client = new SmtpClient(host, port)
- {
- Credentials = new NetworkCredential(from, password),
- EnableSsl = true
- };
- client.Send(mail);
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment