API Questions on Kentico API.
Version 6.x > API > How to send bizform notification email in Kentico 6 View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 11/3/2011 9:14:13 PM
   
How to send bizform notification email in Kentico 6
the following code worked for Kentico 5, but no longer for 6

BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo("BIZFORMNAME", "SITENAME");
if (bfi != null)
{
DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
if (dci != null)
{
GeneralConnection genConn = ConnectionHelper.GetConnection();

// create a new record in memory (new DataClass object)
DataClass formRecord = new DataClass(dci.ClassName, genConn);

// Insert some data
formRecord.SetValue("Email", Request.Form["txtEmail"]);
formRecord.SetValue("FormInserted", DateTime.Now);
formRecord.SetValue("FormUpdated", DateTime.Now);

// Insert the new record in the database
formRecord.Insert();

// Update number of entries in BizFormInfo
bfi.FormItems++;
BizFormInfoProvider.SetBizFormInfo(bfi);

// Dataclass object
IDataClass content = DataClassFactory.NewDataClass(dci.ClassName, formRecord.ID, genConn);
DataRow row = content.DataRow;

CMS.FormControls.BizForm form = new CMS.FormControls.BizForm();

form.SendNotificationEmail(bfi.FormSendFromEmail, bfi.FormSendToEmail, row, bfi, content);
}
}
}


the old code will no longer compile so i have modifed bits and pieces. it inserts data ok (from devnet doco), but I couldn't find how to send a notification email? help?

BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo("BIZFORMNAME", "SITENAME");
if (bfi != null)
{
DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
if (dci != null)
{
BizFormItemProvider bProvider = new BizFormItemProvider();
BizFormItem formRecord = new BizFormItem(dci.ClassName, bProvider);

formRecord.SetValue("Email", Request.Form["Email"]);
formRecord.SetValue("FormInserted", DateTime.Now);
formRecord.SetValue("FormUpdated", DateTime.Now);

formRecord.Insert();
BizFormInfoProvider.RefreshDataCount(bfi.FormName, bfi.FormSiteID);

// Dataclass object

IDataClass content = DataClassFactory.NewDataClass(dci.ClassName, formRecord.ItemID);


CMS.FormControls.BizForm form = new CMS.FormControls.BizForm();
//compiles and doesn't throw exception, but does not email?

form.SendNotificationEmail(bfi.FormSendFromEmail, bfi.FormSendToEmail, , bfi);

}
}
}

User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 11/3/2011 9:15:48 PM
   
RE:How to send bizform notification email in Kentico 6
sorry last line of code (which compiles but doesn't) should be:

form.SendNotificationEmail(bfi.FormSendFromEmail, bfi.FormSendToEmail, content, bfi);

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 11/13/2011 7:42:19 PM
   
RE:How to send bizform notification email in Kentico 6
Hello,

the tested sample code for the 6.0 version is:
BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo("ContactUs", CMSContext.CurrentSiteID);
DataClassInfo classInfo = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
BizFormItem content = new BizFormItem(classInfo.ClassName, new BizFormItemProvider());
content.SetValue("FirstName", "xxx");
content.SetValue("LastName", "zzz");

content.Insert();
bfi.FormItems++;
BizFormInfoProvider.RefreshDataCount(bfi.FormName, bfi.FormSiteID);


BizForm bz = new BizForm();
bz.FormName = bfi.FormName;
bz.BasicForm = new BasicForm(content);
bz.SiteName = CMSContext.CurrentSiteName;

FormInfo fi = FormHelper.GetFormInfo(classInfo.ClassName + ".insert", true);
bz.BasicForm.FormInformation = fi;

bz.SendNotificationEmail("<from>", "<to>", content, bfi);

Best regards,
Helena Grulichova

User avatar
Certified Developer v7
Certified  Developer v7
ben-devotion.com - 11/13/2011 10:36:17 PM
   
RE:How to send bizform notification email in Kentico 6
Thanks Helena that works :)


User avatar
Member
Member
sgolin-insite - 12/17/2012 8:36:37 AM
   
RE:How to send bizform notification email in Kentico 6
What does that code look like in Kentico 7?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 12/18/2012 9:09:30 AM
   
RE:How to send bizform notification email in Kentico 6
Hello,

Have you tried the code before asking? You can take a look at Martin Hejtmanek (CTO)'s Blog for the API changes if it will be necessary.

Best regards,
Martin Danko