public static IEncodedString Link(this ResourceTemplateHelper helper, string path, string contentId, string mediaType, TransferEncoding transferEncoding, CultureInfo culture = null) { Contract.Requires <ArgumentNullException>(helper != null); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(path)); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(contentId)); Contract.Requires <ArgumentException>(!string.IsNullOrEmpty(mediaType)); var resource = helper.Get(path, culture); if (resource == null) { var message = string.Format("Resource [{0}] was not found.", contentId); throw new TemplateHelperException(message); } var linkedResource = new LinkedResource(resource, mediaType) { TransferEncoding = transferEncoding }; helper.AddLinkedResource(linkedResource); var renderedResult = new RawString(string.Format("cid:{0}", contentId)); return(renderedResult); }
public EmailTemplate(TemplateContext templateContext) : base(templateContext) { Contract.Requires<ArgumentNullException>(templateContext != null); _emailContext = templateContext.AddOrGetExisting(EmailContextKey, () => new EmailContext()); Resource = new ResourceTemplateHelper(this, templateContext); }
public EmailTemplate(TemplateContext templateContext) : base(templateContext) { Contract.Requires<ArgumentNullException>(templateContext != null); Attachments = new Collection<Attachment>(); Bcc = new MailAddressCollection(); BodyEncoding = Encoding.UTF8; BodyTransferEncoding = TransferEncoding.Base64; CC = new MailAddressCollection(); DeliveryNotificationOptions = DeliveryNotificationOptions.None; Headers = new NameValueCollection(); HeadersEncoding = Encoding.UTF8; LinkedResources = new Collection<LinkedResource>(); Priority = MailPriority.Normal; ReplyToList = new MailAddressCollection(); To = new MailAddressCollection(); SubjectEncoding = Encoding.UTF8; Resource = new ResourceTemplateHelper(this, templateContext); }