我想用C#发送带有邮件的pdf文件。我知道我可以发送邮件,但我不知道我怎么能发送邮件用PDF文件:(如何用PDF文件发送邮件
比如我在文件夹C PDF文件:\检验.pdf
这里是我的代码:
private void SendEmail(string pdfpath,string firstname, string lastname, string title, string company, string mailfrom,string mailto)
{
try
{
MailMessage m = new MailMessage();
System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient();
m.From = new System.Net.Mail.MailAddress(mailfrom);
m.To.Add(mailto);
m.Subject = "Company Gastzugang (" + lastname + ", " + firstname + ")";
// what I must do for sending a pdf with this email
m.Body = "Gastzugangdaten sind im Anhang enthalten";
sc.Host = SMTPSERVER; // here is the smt path
sc.Send(m);
}
catch (Exception ex)
{
error.Visible = true;
lblErrorMessage.Text = "Folgender Fehler ist aufgetreten: " + ex.Message;
}
}
你需要它作为附件? – ryadavilli