[英]how to send email to particular folder instead of inbox using SMTP c#
how to specify folder path in the below code instead of default inbox folder.如何在下面的代码中指定文件夹路径而不是默认的收件箱文件夹。 how to send email to particular folder instead of inbox using SMTP c#
如何使用 SMTP 将 email 发送到特定文件夹而不是收件箱 c#
static string smtpAddress = "smtp.gmail.com";
static int portNumber = 587;
static bool enableSSL = true;
static string emailFromAddress = "xxxxx"; //Sender Email Address
static string password = "xxxxxxx"; //Sender Password
static string emailToAddress = "xxxx@yyy.vom"; //Receiver Email Address
static string subject = "Hello";
static string body = "Hello, This is Email sending test using gmail.";
public static void SendEmail()
{
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress(emailFromAddress);
mail.To.Add(emailToAddress);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
//mail.Attachments.Add(new Attachment("D:\\TestFile.txt"));//--Uncomment this to send any attachment
using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
{
smtp.Credentials = new NetworkCredential(emailFromAddress, password);
smtp.EnableSsl = enableSSL;
smtp.Send(mail);
}
}
}
The SMTP protocol does not provide a way to send a message to a particular folder for any recipient. SMTP 协议不提供将消息发送到任何收件人的特定文件夹的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.