Hello,
How to Using jQuery to Send Email with Web Services in .net and how to write code for email send in web service?
Please help me.
Thanks in advance
Ankit Agarwal
Software Engineer
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
nitesh bagdiPosted May 5, 2014, 2:18 AM
Error2Could not create type 'WebService'.C:\Users\admin\Downloads\jquerymailusingwebservice\JqueryAutoComplete\WebService.asmx1
Sanjeeb LenkaPosted Aug 23, 2013, 2:59 AM
I am attaching the Working code in Html page with jQuery and webservice to send mail. just download it and open it in visual studio. Run the Html page and check.
Iftikar HussainPosted Aug 23, 2013, 2:29 AM
Ankit AgarwalPosted Aug 23, 2013, 2:28 AM
Sanjeeb LenkaPosted Aug 23, 2013, 2:25 AM
is your service is inside the website or you created it separately.
Iftikar HussainPosted Aug 23, 2013, 2:23 AM
Regards,
Iftikar
Ankit AgarwalPosted Aug 23, 2013, 2:21 AM
var serviceurl =location.protocol + "//" + domain + "/Website/SendingMailWebService.asmx/SendUserMail";
my mail did not send.
Iftikar HussainPosted Aug 22, 2013, 11:13 AM
var serviceurl =location.protocol + "//" + domain + "Website/SendingMailWebService.asmx/SendUserMail";
to
var serviceurl =location.protocol + "//" + domain + "/Website/SendingMailWebService.asmx/SendUserMail";
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 8:55 AM
with my html code:-
but it's not running sucessfully.
Sanjeeb LenkaPosted Aug 22, 2013, 8:36 AM
if you are doing it in Asp .net. i attached a sample above post just check that. if any problem reply.
Ankit AgarwalPosted Aug 22, 2013, 8:28 AM
now i will apply of this web service in my html form.
Sanjeeb LenkaPosted Aug 22, 2013, 8:22 AM
Happy coding.........
Iftikar HussainPosted Aug 22, 2013, 8:18 AM
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 8:17 AM
with gmail smtp.
Sanjeeb LenkaPosted Aug 22, 2013, 8:10 AM
mailbox.EnableSsl = true;
Ankit AgarwalPosted Aug 22, 2013, 8:07 AM
it's not coming in my code.
Iftikar HussainPosted Aug 22, 2013, 8:01 AM
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 22, 2013, 8:00 AM
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(frmMailId,name);
mailMessage.To.Add("my email id");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient mailbox = new SmtpClient("smtp.gmail.com");
mailbox.Port = 587;
mailbox.Credentials = new NetworkCredential("your user id", "your password");
SmtpServer.EnableSsl = true;
mailbox.Send(mailMessage);
return true;
Ankit AgarwalPosted Aug 22, 2013, 7:58 AM
Can it be reason for my error?
Iftikar HussainPosted Aug 22, 2013, 7:53 AM
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 7:52 AM
Here is an error coming with gmail smtp.
Sanjeeb LenkaPosted Aug 22, 2013, 7:47 AM
Ankit AgarwalPosted Aug 22, 2013, 7:35 AM
Here was an error coming.
when we write this code:-
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(frmMailId,name);
mailMessage.To.Add("toEmailID");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient mailbox = new SmtpClient("My smtp");
mailbox.Send(mailMessage);
return true;
My SMTP is Correct.
Iftikar HussainPosted Aug 22, 2013, 7:26 AM
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress(frmMailId,name);
mailMessage.To.Add("my email id");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient mailbox = new SmtpClient("my smtp");
mailbox.Port = my port number;
return true;
Regards,
Iftikar
Sanjeeb LenkaPosted Aug 22, 2013, 7:25 AM
Iftikar HussainPosted Aug 22, 2013, 7:24 AM
[WebMethod]
public bool SendUserMail(string name, string fromMailId, string message)
{
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 7:23 AM
mailMessage.From = new MailAddress(frmMailId,name);
mailMessage.To.Add("my email id");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
mailMessage.Body = message;
SmtpClient mailbox = new SmtpClient("my smtp");
mailbox.Port = my port number;
mailbox.Send(mailMessage);
return true;
my smtp is correct i checked.
Sanjeeb LenkaPosted Aug 22, 2013, 7:20 AM
Iftikar HussainPosted Aug 22, 2013, 7:20 AM
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 7:16 AM
Again error
I am using our smtp details.
Sanjeeb LenkaPosted Aug 22, 2013, 7:06 AM
userNameandpasswordsettings refer to the credentials for connecting to the SMTP server. Make sure you don't confuse this with the username and password for thefromortoaddress, which is not relevant to the SMTP server.the sample is for gmail mailid to send mail to other
Ankit AgarwalPosted Aug 22, 2013, 7:03 AM
Sanjeeb LenkaPosted Aug 22, 2013, 6:50 AM
i am attaching a sample just check that.
Iftikar HussainPosted Aug 22, 2013, 6:49 AM
[WebMethod]
public bool SendUserMail(string name, string fromMailId, string message)
{
in your script
function SendMail() {
var name= $("#txtName").val();
var fromMailId= $("#txtEmail").val();
var message= $("#txtMessage").val();
data: "{ 'name': '" + name + "','fromMailId': '" + fromMailId+ "','message': '" + message+ "' }",
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 6:44 AM
Name:- Ankit
Email:- [email protected]
Message:- Test
SEND
Suppose I clicked On SEND and then message send to another email id, It should not be send to my [email protected].
Msg sholud be send as it is like:-
Name:- Ankit
Email:- [email protected]
Message:- Test
I am confusing that, what is toMailID?, it should be static and from mailid and name should be enter by user.
Iftikar HussainPosted Aug 22, 2013, 6:09 AM
public bool SendUserMail(string name, string toMailId, string message)
{
}
then in your html
var name= $("#txtName").val();
var toMailId= $("#txtEmail").val();
var message= $("#txtMessage").val();
data: "{ 'name': '" + name + "','toMailId': '" + toMailId+ "','message': '" + message+ "' }",
if(result ==true)
{
alert('mail sent');
}
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 5:50 AM
So, How can we do with this html?
Iftikar HussainPosted Aug 22, 2013, 5:46 AM
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 5:39 AM
Iftikar HussainPosted Aug 22, 2013, 4:53 AM
Regards,
Iftikar
arjun singh chouhanPosted Aug 22, 2013, 4:25 AM
Iftikar HussainPosted Aug 22, 2013, 3:45 AM
Create a web method for sending mail like this
using System.Net.Mail;
public void SendUserMail()
{
}
Regards,
Iftikar
Ankit AgarwalPosted Aug 22, 2013, 3:24 AM
I need to Mail.asmx page of this content.
How to write email send code in web service?
Sanjeeb LenkaPosted Aug 22, 2013, 3:19 AM
Refer to this link:
http://blog.image0.com/web-development/using-jquery-to-send-email-with-web-services/