Hello all
This is my second major post and hopefully this post will be of some interest to users in the umbraco community.
I have created a .NET usercontrol for an email to friend feature to use with Umbraco.
I will give you a brief overview of the control and then describe further in detail.
Features
- Checks if node ID querystring is passed to page, if not it displays an error.
- Check if node ID quersytring is valid, and not a made up ID. If not it displays a different error.
- Mailserver, username and password can be set from the umbraco node.
- Custom message for email sent to friend - uses placeholders
- Custom subject line for email sent to friend - uses placeholders
- .NET 2 built in validation
Placeholders that you can use in the email message and subject
- [FriendName]
- [FriendEmail]
- [YourName]
- [YourEmail]
- [Message]
- [Date]
- [Time]
- [URL]
Subject placeholder examples
- Your friend [YourName] has sent you a link
- Hi [FriendName]! [YourName] has sent you a link
Message placeholder example
- Hello [FriendName] your friend [YourName] has sent you a link to check out.
[URL]They have also sent you this message.
[Message]
www.creativewebspecialist.co.uk
I will detail how to set up the Macro and Document Type now.
- Create a New Macro
- Name it an appropiate name - eg: EmailAFriend
- in the .Net User control field type usercontrols/EmailAFriend.acsx
- Upload EmailAFriend.ascx to the folder usercontrols at the root directory
- Add the following parameters - see the screenshot below
Now to create the Document Type
- Add new document type with a matching template
- Name it an appropiate name - eg: EmailAFriend
- Add a new tab called Config
- Add the following node properties - see the screenshot below

Next you need to insert the macro onto the DocumentType template. This should something similar to the following.
Finally you will need a link to the Email a Friend page, which passes the current node id as a querystring. For this I have created a XSLT macro.
Create a new XSLT with macthing Macro and use the following code, obviously ammend the link to your email a friend page.
Email this page
I won't go into detail about the .ascx .NET usercontrol VB code as it is very heavily commented, but if you have any problems with it please leave a comment and I'll explain it further in detail.