示例#1
0
 private void AddLinkedResources(LinkedResourceCollection linkedResourceCollection, Dictionary <string, byte[]> linkedResources)
 {
     foreach (var linkedResource in linkedResources ?? Enumerable.Empty <KeyValuePair <string, byte[]> >())
     {
         var lres = new LinkedResource(new MemoryStream(linkedResource.Value), MimeTypeResolver.Resolve(linkedResource.Key))
         {
             ContentId = linkedResource.Key
         };
         linkedResourceCollection.Add(lres);
     }
 }
 public LinkedResourceCollectionTest()
 {
     lrc = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")).LinkedResources;
     lr = LinkedResource.CreateLinkedResourceFromString("test", new ContentType("text/plain"));
 }
示例#3
0
		private void SendLinkedResources (MailMessage message, LinkedResourceCollection resources, string boundary)
		{
			foreach (LinkedResource lr in resources) {
				StartSection (boundary, lr.ContentType, lr);

				switch (lr.TransferEncoding) {
				case TransferEncoding.Base64:
					byte [] content = new byte [lr.ContentStream.Length];
					lr.ContentStream.Read (content, 0, content.Length);
#if TARGET_JVM
					SendData (Convert.ToBase64String (content));
#else
					    SendData (Convert.ToBase64String (content, Base64FormattingOptions.InsertLineBreaks));
#endif
					break;
				case TransferEncoding.QuotedPrintable:
					byte [] bytes = new byte [lr.ContentStream.Length];
					lr.ContentStream.Read (bytes, 0, bytes.Length);
					SendData (ToQuotedPrintable (bytes));
					break;
				case TransferEncoding.SevenBit:
				case TransferEncoding.Unknown:
					content = new byte [lr.ContentStream.Length];
					lr.ContentStream.Read (content, 0, content.Length);
					SendData (Encoding.ASCII.GetString (content));
					break;
				}
			}
		}
示例#4
0
 public MailBuilder EmbedImages(LinkedResourceCollection resources)
 {
     return(this.EmbedImages(resources.ToList()));
 }
 /// <summary>
 /// The embed images.
 /// </summary>
 /// <param name="resources">
 /// The resources.
 /// </param>
 /// <returns>
 /// The <see cref="SendGridMessageBuilder"/>.
 /// </returns>
 public SendGridMessageBuilder EmbedImages(LinkedResourceCollection resources)
 {
     return(this.EmbedImages(resources.ToList()));
 }
 public void GetReady()
 {
     lrc = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")).LinkedResources;
     lr  = LinkedResource.CreateLinkedResourceFromString("test", new ContentType("text/plain"));
 }
 public MailBuilder EmbedImages(LinkedResourceCollection resources)
 {
     return this.EmbedImages(resources.ToList());
 }
		public void GetReady ()
		{
			lrc = AlternateView.CreateAlternateViewFromString ("test", new ContentType ("text/plain")).LinkedResources;
			lr = LinkedResource.CreateLinkedResourceFromString ("test", new ContentType ("text/plain"));
		}
示例#9
0
 public LinkedResourceCollectionTest()
 {
     lrc = AlternateView.CreateAlternateViewFromString("test", new ContentType("text/plain")).LinkedResources;
     lr  = LinkedResource.CreateLinkedResourceFromString("test", new ContentType("text/plain"));
 }