Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Content-type: text/html; charset=US-ASCII
- Content-Disposition: inline
- Content-transfer-encoding: quoted-printable
- Content-type: text/plain; name="..."
- Content-Disposition: attachment; filename="..."
- Content-transfer-encoding: base64
- //Для отправки почты
- static void SendMail()
- {
- string smtpHost = "хост почтовик";
- int smtpPort = порт;
- string login = "логин";
- string pass = "пароль";
- //connect
- SmtpClient client = new SmtpClient(smtpHost, smtpPort);
- client.Credentials = new NetworkCredential(login, pass);
- //from-to-title-body message
- string from = "test@gmail.com";
- string to = "test1@gmail.com, test2@gmail.com";
- string subject = "Test header";
- string body = "Это тестовая рассылка, проверьте вложение";
- //attachment
- Attachment attData = new Attachment(@"C:test.xlsx");
- //create message and attaching
- MailMessage mess = new MailMessage(from, to, subject, body);
- mess.Attachments.Add(attData);
- try
- {
- client.Send(mess);
- MessageBox.Show("Сообщение отправлено");
- }
- catch (SmtpException ex)
- {
- MessageBox.Show(ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement