有没有办法将System.Drawing.Image附加到电子邮件而不保存它,然后从保存的路径中抓取它.
现在我正在创建图像并保存它.然后我发送电子邮件:
MailMessage mail = new MailMessage();
string _body = "body"
mail.Body = _body;
string _attacmentPath;
if (iP.Contains(":"))
_attacmentPath = (@"path1");//, System.Net.Mime.MediaTypeNames.Application.Octet));
else
_attacmentPath = @"path2");
mail.Attachments.Add(new Attachment(_attacmentPath, System.Net.Mime.MediaTypeNames.Application.Octet));
mail.To.Add(_imageInfo.VendorEmail);
mail.Subject = "Rouses' PO # " + _imageInfo.PONumber.Trim();
mail.From = _imageInfo.VendorNum == 691 ? new MailAddress("email", "") : new MailAddress("email", "");
SmtpClient server = null;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.Normal;
server = new SmtpClient("server");
try
{
server.Send(mail);
}
catch
{
}
Run Code Online (Sandbox Code Playgroud)
无论如何直接将System.Drawing.Image传递给mail.Attachments.Add()?