Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6047033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:18:25+00:00 2026-05-23T07:18:25+00:00

I have a function for sending email. This function works normally, but it always

  • 0

I have a function for sending email.
This function works normally, but it always triggers the error function, any error did not occur (I’m receiving email).

Follow my Javascript:

//Send mail
$("div.contato-pedidooracao form").submit(function () {

    var dataString = $(this).serialize();
    $.ajax({
        type: "POST",
        url: "Contato/SendMail",
        data: dataString,
        dataType : "json",
        success: function (data) { alert("OK"); },
        error: function (data) { alert("Error"); }

    });
});

Controller

[HttpPost]
public ActionResult SendMail(string name, string phone, string cel, string email, string message)
{
    try
    {
        using (var mail = new MailMessage())
        {

            mail.To.Add("--mailhere--");

            mail.From = new MailAddress("\"" + name + "\" <" + email + ">" );
            mail.Subject = "Pedido de Oração - " + name;
            mail.Body = message;
            mail.IsBodyHtml = false;

            new SmtpClient().Send(mail);
        }
        return Json(new{Sucess = true, Message = "Email enviado com sucess!" } );

    }
    catch (Exception ex)
    {
        return Json(new{Sucess = false, Message = ex.Message } );
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:18:26+00:00Added an answer on May 23, 2026 at 7:18 am

    I believe you need to add event.preventDefault to stop the submit event from bubbling up and really submitting the form to the server.

    $("div.contato-pedidooracao form").submit(function (event) {
       event.preventDefault();
       ..... 
       .....
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function sending an email twice (and I believe running if($result)
I am sending email newsletters using php mail() function. I have to track the
I have a cron job set up to run testemail.php. This works fine, every
So I have been having a hard time sending email from my school's email
as in asp we have function to send complete web page in email, which
I came across an interesting problem today. I have a text email I'm sending
I have a problem when sending a form via email using the PHP Mail
I have this AJAX: function sendMail () { $.post('php/sendMail.php', function(result){ alert(result); }) } $('#submitContact').click(function(){
I have a MailMessage class I've written to manage sending email from my application.
I have a php function which is called by a jquery function. This jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.