Мой текущий проект требует отправки электронной почты пользователю с более чем одним вложенным файлом. Я использую dll send grid mail для отправки почты. я много искал, но не нашел надежного решения. Кто-нибудь может помочь? Вот мой код:
public void SimpleHTMLEmailWithAttachment(String emailBody, String subject, MailId mailId, System.IO.MemoryStream ms, String fileName)
{
//create a new message object
var message = SendGrid.GetInstance();
//set the message recipients
message.AddTo(this.to);
//set the sender
message.From = new MailAddress(from);
//set the message body
message.Html = emailBody;
//set the message subject
message.Subject = subject;
//set the attachment
message.AddAttachment(ms, fileName);
//set unique identifier
Dictionary<String, String> identifier = new Dictionary<String, String>();
identifier.Add("MailId", mailId.AsString());
message.Header.AddUniqueIdentifier(identifier);
//create an instance of the Web transport mechanism
var transportInstance = Web.GetInstance(new NetworkCredential(userName, password));
//send the mail
transportInstance.Deliver(message);
}