Posted on 23/06/2014 11:19:56
Hi Jonas,
It would seem that you're working with an older version of the API, probably from during the beta phase of the module. Some of those methods you use are no longer available. The production assemblies might be version 8.4.0.3, but your development assemblies are probably not newer than 8.2.3.x. CreateSendScheduledTask was renamed in 8.3.0.0 to CreateEmailScheduledTask, and CreateMessage was made private and replaced by CreateMessageForOriginal and CreateMessageForVariation in 8.3.1.0. Neither of which you actually need to call yourself.
You should make sure that the development assemblies you use are the same as the ones in the production environment.
In addition, what you're trying to do is not what E-mail Marketing was designed to do. E-mail Marketing is meant to send the contents of a page / item, not a template directly. The Template property can be used to change the layout template of the page when the page is being rendered.
Something like this
public void CreateScheduledEmail()
{
var email = new Email();
// Set standard properties
email.SenderEmail = "noreply@domain.com";
email.SenderName = "My name";
email.Subject = "My subject";
//And so on
// Setup content
email.PageId = 50;
// Setup recipients
var recipientProvider = new AccessUserRecipientProvider();
recipientProvider.Email = email;
// All ids are AccessUser ids with the following prefix
// Users: 'u'
// Groups: 'g'
// SmartSearches: 's'
// Assume users with ids 1000, 1200 and 1201
// and users in the group with id 1500 are the recipients
recipientProvider.SetIds(new List< string > { "u1000", "u1200", "u1201", "g1500" });
email.RecipientProviderConfiguration = recipientProvider.GetParametersToXML();
// Setup scheduling
// Schedules the e-mail for single execution next time the scheduler runs.
// Scheduler runs every 5 minutes, so the execution happens anywhere from Now to Now+5
email.CreateEmailScheduledTask(DateTime.Now);
// No need to save the e-mail as CreateEmailScheduledTask does that.
}
This should be enough, but if you run into any issues, please let me know :)
- Jeppe