Email Send in Web Service,HtmlPage Using Asp.Net C# JQuery

Email Send in Web Service,HtmlPage Using  Asp.Net C# JQuery

Email Send To Users  Using Web Service & HtmlPage.html  in JQuery,JavaScript With GoogleApis in Asp.Net C#(Without Using WebForm).

                             Download Coding


                       HTML CODING(HtmlPage.html)

<!DOCTYPE html>
<html xmlns="">

    <link href=""
        rel="stylesheet" type="text/css"/>
    <script src=""></script>
    <script src=""></script>
        function SendMail() {
            $("#Button1").click(function () {
                    url: "WebService.asmx/MailSend",
                    data: "{ 'To': '" + $('input[id$=Text1]').val() +
                  "', 'Message': '" + $('input[id$=Text2]').val() + "' }",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        if (data.d == 1) {
    <input id="Text1" type="text" /></td></tr>
    <input id="Text2" type="text" /></td></tr>
        <tr><td colspan="2">
    <input id="Button1"  type="button"  onclick ="SendMail();" value="SEND MAIL"  /></td></tr>


                           Web Service.asmx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Net.Mail;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
public class WebService : System.Web.Services.WebService {  
    public  int MailSend(string To, string Message)
        MailMessage Msg = new MailMessage();
        Msg.From = new MailAddress(""); // Sender e-mail address.
        Msg.To.Add(To);// Recipient e-mail address.
        Msg.Subject = "Send Mail Using WebServices";
        Msg.Body = Message;
        Msg.IsBodyHtml = true;     
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "";
        smtp.Port = 587;
        smtp.Credentials = new System.Net.NetworkCredential("", "Password");
        smtp.EnableSsl = true;
        return 1;      

First - Add New HtmlPage.html Form  

Next - Add Input Button.Button From ToolBox

Next - Add - Web Service.asmx From Solution Explorer

Next - Add JQuery,GoogleApi  &  JQuery Function From WebService.asmx

Next - Add - NameSpace(using System.Net.Mail)Email Send Coding  in WebService.asmx  Input Call From HtmlPage.html


Post a Comment