[英]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.