Esempio n. 1
0
 public static Attachment FromStream(Stream stream, string attachmentName, string mimeType = null)
 {
     return(new Attachment
     {
         Stream = stream,
         Name = attachmentName,
         Mime = MimeHelper.GetMimeType(new FileInfo(attachmentName).Extension),
     });
 }
Esempio n. 2
0
 /// <summary>
 /// Create attachment from a file on disk
 /// </summary>
 /// <param name="file">File to attach</param>
 /// <param name="attachmentName">Optional, filename is used by default</param>
 /// <returns></returns>
 public static Attachment FromFile(FileInfo file, string attachmentName = null)
 {
     return(new Attachment
     {
         File = file,
         Name = attachmentName ?? file.Name,
         Mime = MimeHelper.GetMimeType(file.Extension)
     });
 }