I need to add an attachment to the newsletter. I already use a render-task to replace first- and lastname...
I also use the function "Insert dynamic content from URL" to create the content from the newsletter.
My question is: Is there a way to add a MediaPicker on the page in the content-area and add it as attachment to the newsletter? Or has any body another idea?
If you are sending from the content area this should be possible if you create a render task that gets the URL to the file and then attach the file to the MailMessage-class.
I don't have any code examples but on the newsletter-object there is a property that contains the nodeid (if it is a node) this could be used and then you could get the IPublishedContent-item to figure out the medie file url.
Did you press "save and publish" before you tried to send? I think that you need to do this before the content get updated in the newsletter node.
Edit: This will only work if you are sending from the content-section, in other words if the newsletter is created from a umbraco node.
Edit2: It looks like you are trying to render the node using the "Insert content url"-feature? That would not work with this solution - if you need that solution one option would be to replace the default rendertask for "InsertUrl" with a custom one that inserts the attachment.
This is the code for the default "RenderUrlRenderTask.cs", if you use this as your starting-point, get the node based on the URL and then get that IPublishedContent and look if there is an attachment.
The thing is that when you send from the content section, the newsletter will be connected to the node that is used to create it. When you are using the "insert url content"-feature there is no real connection except for the URL that is entered - this could even be an external URL on another website.
Great that you got it working =D
Please let me know if you have any other questions etc.
I am working on similar use case to add attachment to the newsletter.
Can you share the RenderTask code snippet that you manage to get it working? I have seen the two different snippet above and wondering how you get on with creating add attachment rendertask.
Many thanks for sharing your use case and rendertask !
I was using the Newsletter standalone section and wasnt quite sure on how to operate the RenderTask only when its used in Content Section.
Looking for ContentId and perhaps a flag within RenderTask should not disturb Newsletter Section standalone usage along with occasional Content section usage.
Add a file as attachment to the e-mail
Hello @all,
I need to add an attachment to the newsletter. I already use a render-task to replace first- and lastname...
I also use the function "Insert dynamic content from URL" to create the content from the newsletter.
My question is: Is there a way to add a MediaPicker on the page in the content-area and add it as attachment to the newsletter? Or has any body another idea?
Thank you for your help!
Hi!
If you are sending from the content area this should be possible if you create a render task that gets the URL to the file and then attach the file to the MailMessage-class.
I don't have any code examples but on the newsletter-object there is a property that contains the nodeid (if it is a node) this could be used and then you could get the IPublishedContent-item to figure out the medie file url.
// m
Hi again Jeremias!
This is an example of how this can be done: https://gist.github.com/enkelmedia/e3d9ff59d38bb36575d7af19d6ad61c1
Details about render tasks and how to configure them can be found here: http://support.newsletterstudio.org/customer/en/portal/articles/1052872-control-content-with-render-tasks
Hope that this helps to solve your problems!
Hi Markus,
thank you for your code-snippet. That's great! Thank you!
But now I have the problem, that parameters.Newsletter.ContentNodeId is NULL...
Here the pictures from the Content-Node and from the Newsletter:
Is there one more thing to do, that the ContentNodeId gets saved in the parameters?
Hi!
Did you press "save and publish" before you tried to send? I think that you need to do this before the content get updated in the newsletter node.
Edit: This will only work if you are sending from the content-section, in other words if the newsletter is created from a umbraco node.
Edit2: It looks like you are trying to render the node using the "Insert content url"-feature? That would not work with this solution - if you need that solution one option would be to replace the default rendertask for "InsertUrl" with a custom one that inserts the attachment.
This is the code for the default "RenderUrlRenderTask.cs", if you use this as your starting-point, get the node based on the URL and then get that IPublishedContent and look if there is an attachment.
https://gist.github.com/enkelmedia/79ea9a81d09d2fb4f74206584a834a7d
I would say that this is a quite "hacky" solution, I would go for the "Send out"-data type in the content-section:
http://support.newsletterstudio.org/customer/en/portal/articles/1053067-sending-from-the-content-section
// m
Hi!
Thank you!
That war my problem. I added the Newsletter Sendout to the Documenttype and it works :)
Thank you for helping!
Cool!
The thing is that when you send from the content section, the newsletter will be connected to the node that is used to create it. When you are using the "insert url content"-feature there is no real connection except for the URL that is entered - this could even be an external URL on another website.
Great that you got it working =D
Please let me know if you have any other questions etc.
// m
Hi,
now I have one more question to this: Is it also possible to attach the file to the test-email? Now it is only attached in the 'real' sending...
Hi!
No, not at the moment as we're not passing the MailMessage-object to the pre-render methods.
My tip would be to send a "real" message to a list of test-subscibers (like your self and some collegues or something).
// m
Ok. No problem. Thank you!
Hi Jeremias
I am working on similar use case to add attachment to the newsletter.
Can you share the RenderTask code snippet that you manage to get it working? I have seen the two different snippet above and wondering how you get on with creating add attachment rendertask.
Hi Keilo,
of course! Here is my RenderTask to attach the file:
I use the newsletterstudio like this: I have a content-Node which is rendering the whole content for the Newsletter:
On the same page I have the sendout: This is necessary, that the the RenderTask knows from wich page he should take the Attachment.
I hope this helps you!
it's also helpful to watch the last two videos on this page:
https://www.newsletterstudio.org/videos/
(Send newsletters from the content section, Work with the content using Render Tasks)
That looks cool Jeremias!
Many thanks for sharing your use case and rendertask !
I was using the Newsletter standalone section and wasnt quite sure on how to operate the RenderTask only when its used in Content Section. Looking for ContentId and perhaps a flag within RenderTask should not disturb Newsletter Section standalone usage along with occasional Content section usage.
is working on a reply...