有没有办法在不保存图片并从已保存的路径中获取它的情况下,将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
{
}
有没有办法直接将System.Drawing.Image传递给mail.Attachments.Add()方法作为附件?