我该如何在正文内容中添加一张图片?我已经编写了以下代码:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
string UserName = "xyz@someorg.com";
string Password = "my password";
message.To.Add(new System.Net.Mail.MailAddress("toaddress@toadddress.com"));
message.From = new System.Net.Mail.MailAddress("fromaddress@fromaddress.com");
message.Subject = "test subject";
message.Body = "<img src=@'C:\\Sunset.jpg'/>";
message.IsBodyHtml = true;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
smtpClient.Host = "hostname";
smtpClient.Port = 25;
smtpClient.Credentials = new System.Net.NetworkCredential(UserName, Password);
smtpClient.Send(message);
代码没问题,因为我收到了消息,但是图片在邮件正文中显示为[X],而不是图片。怎么解决?路径正确吗?