Accessing email module from a custom module

Topics: Customizing Orchard
Oct 14, 2014 at 3:35 PM
I am bringing in our current Ticketing System into an orchard site for our Intranet. As such, it doesn't really interact with most of the Orchard system except for the menu and themes. What I would like to do is use the Email module to send emails from the custom module, but I am not sure on how I would reference the Email settings from the system, or just be able to hook into the Email workflow. Thanks for any help, or directions to look!
Oct 15, 2014 at 12:57 AM
I am not 100% what you want to do, but maybe you can achieve it with workflows (Workflow Module) and maybe custom tokens?
Oct 15, 2014 at 10:42 PM
One way is like benschi11 suggests. You would trigger some Workflows event from your module, and then some workflow would execute. This workflow could have an SendEmail activity.

Another way is to leverage the IMessageService that is provided by the framework. You would pass in "Email" for the type argument, and a dictionary of parameters that the SMTP channel expects. If you add a project reference to Orchard.Email, you could use SmtpMessageChannel.MessageType instead of hardcoding the "Email" type. Checkout the EmailActivity in Orchard.Email to see how you can send emails from code.