Inheritance: AttachmentBase
コード例 #1
0
ファイル: Mail.cs プロジェクト: ehenson/sendgridplus-csharp
        /// <summary>
        /// Add a stream as an attachment to the message
        /// </summary>
        /// <param name="stream">Stream of file to be attached</param>
        /// <param name="name">Name of file to be attached</param>
        /// <param name="contentType">Content type of stream</param>
        public void AddAttachment(Stream stream, string name, string contentType)
        {
            var ms = new MemoryStream();

            stream.CopyTo(ms);
            ms.Seek(0, SeekOrigin.Begin);
            var attachment = new StreamAttachment(ms, name)
            {
                ContentType = contentType
            };

            _attachments.Add(attachment);
        }
コード例 #2
0
 /// <summary>
 /// Add a stream as an attachment to the message
 /// </summary>
 /// <param name="stream">Stream of file to be attached</param>
 /// <param name="name">Name of file to be attached</param>
 /// <param name="contentType">Content type of stream</param>
 /// <param name="contentId">ContentId for embedding images</param>
 public void AddAttachment(Stream stream, string name, string contentType, string contentId)
 {
     var ms = new MemoryStream();
     stream.CopyTo(ms);
     ms.Seek(0, SeekOrigin.Begin);
     var attachment = new StreamAttachment(ms, name)
     {
         ContentType = contentType,
         ContentId = contentId
     };
     _attachments.Add(attachment);
 }