ASPX templates
Version 4.x > ASPX templates > Manually Send BizForm Notification Email View modes: 
User avatar
Certified Developer 8
Certified Developer 8
bryan-bit-wizards - 11/13/2009 11:05:34 AM
   
Manually Send BizForm Notification Email
Is it possible to send a BizForm notification email manually?

1. I have created a Bizform and configured it to send notification emails.
2. I have a form in which the users inputs data.
3. I take that data and manually insert it into my BizForm table
Using the following example: http://devnet.kentico.com/docs/devguide/index.html?bizforms_api.htm
4. I am successfully inserting the record.

At that point, I want to manually send the notification mail containing all of the BizForm data (exactly like the system would had I added a BizForm control to a page).

Is this possible?

-Bryan

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 11/13/2009 4:08:25 PM
   
RE:Manually Send BizForm Notification Email
Hi,

Yes, this is possible.

Please find example PSEUDO code below (Please note that you might adjust this code, because this is just an example pseudo code):

string bizFormName = "TestingSiteContactUs";
string siteName = "CMSTestingSite";

// Read BizForm definition
BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(bizFormName, siteName);
// Read data type definition
DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
GeneralConnection genConn = ConnectionHelper.GetConnection();

//save the data into bizform table using the example code
// …

// formRecord.ID is taken from the example code from developer’s guide

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

if (!(formItem.IsEmpty()))
{
DataRow row = content.DataRow;
}

// Get confirmation sender and recepient email addresses
object email = DataHelper.GetDataRowValue(row, bfi.FormConfirmationEmailField);
string sendConfirmEmailTo = ValidationHelper.GetString(email, "");
string sendConfirmEmailFrom = bfi.FormConfirmationSendFromEmail;

// Get sender and recipient email addresses
string sendFromEmail = bfi.FormSendFromEmail;
string sendToEmail = bfi.FormSendToEmail;

bool sendEmailtoAdmin = ((!String.IsNullOrEmpty(sendFromEmail)) && (!String.IsNullOrEmpty(sendToEmail)));
bool sendEmailtoCustomer = ((!String.IsNullOrEmpty(sendConfirmEmailFrom)) && (sendConfirmEmailTo != ""));

if (sendEmailtoAdmin || sendEmailtoCustomer)
{

if (sendEmailtoAdmin)
{

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


// Send notification e-mail
bizform.SendNotificationEmail(sendFromEmail, sendToEmail, row, bfi, content);
}

if (sendEmailtoCustomer)
{

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

// Send confirmation e-mail
bizform.SendConfirmationEmail(sendConfirmEmailFrom, sendConfirmEmailTo, row, bfi);
}
}


I hope this will help you.

Best regards,
Miroslav Remias.