예제 #1
0
 public string[] ToMimeString()
 {
     return(new string[]
     {
         "Content-Type: " + MimeHelper.GetMimeType(FilePath) + "; name=\"" + FileName + "\"",
         "Content-Disposition: attachment; filename=\"" + FileName + "\"",
         "Content-Transfer-Encoding: base64",
         "",
         Convert.ToBase64String(_content)
     });
 }
예제 #2
0
        public MailMessage(string from, IEnumerable <string> to, string subject, string body, IEnumerable <string> attachmentNames = null)
        {
            From    = new MailAddress(from);
            To      = to.Select(x => new MailAddress(x));
            Subject = subject;
            Body    = string.Join(Environment.NewLine, body.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
                                  .Select(x => x.Length > 0 && x[0] == '.' ? x = "." + x : x));
            Attachments = attachmentNames == null?Enumerable.Empty <Attachment>() : attachmentNames.Select(x => new Attachment(x));

            _boundary = MimeHelper.GenerateBoundary();
        }