email/sms
-
i have a webpg where our employers can send an email to the clients. i have designed the relevant UI but need the code to send an email to the appropriate recipient when our users clicks the "SEND EMAIL" button. using C#
-
i have a webpg where our employers can send an email to the clients. i have designed the relevant UI but need the code to send an email to the appropriate recipient when our users clicks the "SEND EMAIL" button. using C#
This is one of the most used and common functionality in any application. You have to use Following namespace,
Using System.Net.Mail
Sample Code :
MailMessage Mail = new MailMessage(); MailAddress mailAdd = new MailAddress(txtFrom.Text,txtName.Text); Mail.From = mailAdd ; Mail.To.Add(txtTo.Text); Mail.Subject = txtSubject.Text; Mail.Body = txtComment.Text; try { SmtpClient Objsmtp = new SmtpClient(); Objsmtp .Host = "myMailServer"; Objsmtp .Send(Mail); } catch (Exception ex) { //Handel Exception }
If you serach google, you will get many example on same. :) Note : Please configure your
SMTP Server
properly before starting and testing it.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article
-
i have a webpg where our employers can send an email to the clients. i have designed the relevant UI but need the code to send an email to the appropriate recipient when our users clicks the "SEND EMAIL" button. using C#
bhadilov wrote:
but need the code to send an email to the appropriate recipient when our users clicks the "SEND EMAIL" button
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
This is one of the most used and common functionality in any application. You have to use Following namespace,
Using System.Net.Mail
Sample Code :
MailMessage Mail = new MailMessage(); MailAddress mailAdd = new MailAddress(txtFrom.Text,txtName.Text); Mail.From = mailAdd ; Mail.To.Add(txtTo.Text); Mail.Subject = txtSubject.Text; Mail.Body = txtComment.Text; try { SmtpClient Objsmtp = new SmtpClient(); Objsmtp .Host = "myMailServer"; Objsmtp .Send(Mail); } catch (Exception ex) { //Handel Exception }
If you serach google, you will get many example on same. :) Note : Please configure your
SMTP Server
properly before starting and testing it.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article
-
bhadilov wrote:
but need the code to send an email to the appropriate recipient when our users clicks the "SEND EMAIL" button
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
thanx jana.. i see why you da code MVP. well any ideas how i could get a free SMTP server cause we are still starting up and dont have the funds for the monthly rentals on the ones available on the net.. :thumbsup: :-D
bhadilov wrote:
how i could get a free SMTP server
Thats depedens of which IIS Server (IIS 6.0 or IIS 7.0 ) you are using. Here is some article, which I prefer to give other who are just trying to configure SMTP, SMTP Server Setup (IIS 6.0) and Configuring the SMTP Server Hope this will help you to move ahead :-D Let me know if you have face any problem :)
Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article
-
thanx jana.. i see why you da code MVP. well any ideas how i could get a free SMTP server cause we are still starting up and dont have the funds for the monthly rentals on the ones available on the net.. :thumbsup: :-D
bhadilov wrote:
well any ideas how i could get a free SMTP server
Gmail has free SMTP support. :)
Navaneeth How to use google | Ask smart questions