【问题标题】:The file is not sent to the mail. (Only path)该文件未发送到邮件。 (唯一路径)
【发布时间】:2020-09-08 10:47:58
【问题描述】:

我有这个代码:

        epost.From = new MailAddress("test.31@gmail.com");
        epost.To.Add(textBoxMail.Text.ToString());
        epost.Subject = textBoxSubject.Text.ToString();
        epost.Body = "c:\\Users\\Raşit\\AppData\\Local\\MyText.txt"; //But i have a problem :(

        SmtpClient smpt = new SmtpClient();

        smpt.Credentials = new System.Net.NetworkCredential("test.31@gmail.com", "mypassword");
        smpt.Host = "smtp.gmail.com";
        smpt.EnableSsl = true;
        smpt.Port = 587;

        smpt.Send(epost);
        MessageBox.Show("Done!");

然后我开始调试,我看到了这个:

我只想要文件,我不想要路径。

【问题讨论】:

    标签: c# forms winforms


    【解决方案1】:
    System.Net.Mail.Attachment attachment;
    attachment = new System.Net.Mail.Attachment("c:\\Users\\Raşit\\AppData\\Local\\MyText.txt");
    epost.Attachments.Add(attachment);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 2013-07-18
      • 1970-01-01
      • 2012-07-08
      • 2015-10-15
      • 1970-01-01
      相关资源
      最近更新 更多