如何在 C# 中使用 smtp 发送记录的电子邮件?

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);  
}

但是我在发送的邮件中看不到它。

简答:你不能。

将邮件添加到“已发送”文件夹的唯一方法是使用 IMAP 协议(​​或通过实现 IMAP 协议的库)自己专门将其添加到那里。