You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AttachmentRendertask : Services.RenderTasks.RenderTask
{
string _attachmentPath = String.Empty;
public override void ProcessPreRender(RenderResult renderResult, RenderTaskParameters parameters)
{
// This method is executed when the scheduled jobs web request is still running. This means that the UmbracoContext, ApplicationContext etc can still be used.
// Let's save the path to the attachment media file here.
// Check if this newsletter is connected to a content node (if the ContenNodeId-property has a value the letter is created from that node in the content section).
if (parameters.Newsletter.ContentNodeId.HasValue && parameters.Newsletter.ContentNodeId.Value > 0)
{
// Get this node as a IPublishedContent-object
var helper = new UmbracoHelper(UmbracoContext.Current);
var node = helper.TypedContent(parameters.Newsletter.ContentNodeId);
// Check that there is an attachment-property defined (this could be any name of the property, attachement is just an example).
if (!node.HasProperty("attachment") || node.GetPropertyValue<int>("attachment") <= 0)
return;
var attachmentMediaId = node.GetPropertyValue<int>("attachment");
var property = helper.TypedMedia(attachmentMediaId);
Thanks for the feedback! I've updated the support article with some more details on this. Hope this make it more clear. All the best!