[英]How to send logged email using smtp in c#?
我想知道如何在 c# 中通过 smtp 发送记录的电子邮件(在已发送的项目中可见)。
我正在使用的模型:
try
{
SmtpClient mailServer = new SmtpClient("smtp.gmail.com", 587);
mailServer.EnableSsl = true;
mailServer.Credentials = new System.Net.NetworkCredential("myemail@gmail.com", "mypassword");
string from = "myemail@gmail.com";
string to = "reciever@gmail.com";
MailMessage msg = new MailMessage(from, to);
msg.Subject = "Enter the subject here";
msg.Body = "The message goes here.";
msg.Attachments.Add(new Attachment("D:\\myfile.txt"));
mailServer.Send(msg);
}
catch (Exception ex)
{
Console.WriteLine("Unable to send email. Error : " + ex);
}
但是我在发送的邮件中看不到它。
简短的回答:你不能。
将消息添加到 Sent 文件夹的唯一方法是使用 IMAP 协议(或通过实现 IMAP 协议的库)自己将其添加到那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.