PDA

View Full Version : Using ExtJs and C# to send email



Centric
12 Dec 2013, 3:48 AM
Hi,

I have a form which is updating my database when the Submit button is clicked using the following example: http://www.sencha.com/forum/showthread.php?146351-how-to-submit-my-data-to-save-in-database.

One of the fields in the form is an email textbox, when the user enters their email I need to send them a confirmation email 'Thanks for your interest etc...' after they click Submit.

I have my C# code ready

public static void EmailSend()
{
try
{
string to = "[USERS EMAIL ADDRESS BASED ON EMAIL TEXT FIELD]";
string from = "[EMAIL ADDRESS]";
MailMessage mail = new MailMessage( from , to );
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "[HOST NUMBER'";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}

I need help firing my C# method from ExtJS to send my email, a nudge in the right direction would be appreciated.

bricemason
16 Dec 2013, 6:27 AM
You can start by reviewing the docs for form handling:

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.Panel
http://docs.sencha.com/extjs/4.2.2/#!/guide/forms

and executing ajax requests:

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Ajax

Brice