发送邮件
SmtpClient client = new SmtpClient("smtp.qq.com"); client.UseDefaultCredentials = true; client.Credentials = new System.Net.NetworkCredential("xxxxxxxxx", "xxxxxxxxx"); client.DeliveryMethod = SmtpDeliveryMethod.Network; string file = @"D:发邮件代码 - 副本.txt"; MailMessage message = new MailMessage( "xxxxxxxxx@qq.com", "xxxxxxxxx@qq.com", "自动邮件", "请勿回复!"); // Create the file attachment for this e-mail message. Attachment data = new Attachment(file, MediaTypeNames.Application.Octet); // Add time stamp information for the file. ContentDisposition disposition = data.ContentDisposition; disposition.CreationDate = System.IO.File.GetCreationTime(file); disposition.ModificationDate = System.IO.File.GetLastWriteTime(file); disposition.ReadDate = System.IO.File.GetLastAccessTime(file); //Add the file attachment to this e-mail message. message.Attachments.Add(data); client.Send(message); data.Dispose();