- What version are you working in.
- What does your event handler look like?
- Where are you attempting to read this info?
Some event handlers don't have their respective context available due to when it is processed while others do. With the email queue, you will need to use the Global Object Events.
Your code might look like this:
using CMS;
using CMS.DataEngine;
using CMS.EmailEngine;
using CMS.Helpers;
// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomEmailEngineModule))]
public class CustomEmailEngineModule : Module
{
// Module class constructor, the system registers the module under the name "CustomEmailEngine"
public CustomEmailEngineModule()
: base("CustomEmailEngine")
{
}
// Contains initialization code that is executed when the application starts
protected override void OnInit()
{
base.OnInit();
// Assigns a handler to the Insert.After event for the ForumGroupInfo object type
// This event occurs after the creation of every new email is added
EmailInfo.TYPEINFO.Events.Insert.After += Emailinfo_Insert_After;
}
private void Emailinfo_Insert_After(object sender, ObjectEventArgs e)
{
// Checks that the email object group was successfully created
if (e.Object != null)
{
EmailInfo email = (EmailInfo)e.Object;
// do your work here
string htmlBody = email.EmailBody;
string plainTextBody = email.EmailPlainTextBody;
}
}
}
The body should be completely rendered HTML with no macros in it. Those should have been resolved when the email was added to the queue.