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 6171771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:27+00:00 2026-05-23T23:16:27+00:00

I am trying to use the below code to send email from asp.net(C#). using

  • 0

I am trying to use the below code to send email from asp.net(C#).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using MovieReviews.Utils;

/// <summary>
/// Summary description for EmailUtil
/// </summary>
public class EmailUtil
{
public static void SendEmail(string to, string name, string from, string body)
{
    try
    {
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();

        MailAddress fromAddress = new MailAddress(from, name);

        smtpClient.Host = "localhost";

        //Default port will be 25

        smtpClient.Port = 25;

        //From address will be given as a MailAddress Object

        message.From = fromAddress;

        // To address collection of MailAddress

        message.To.Add(to);
        message.Subject = "Feedback";


        message.IsBodyHtml = false;

        // Message body content

        message.Body = body;

        // Send SMTP mail

        smtpClient.Send(message);

    }
    catch (Exception ex)
    {
        Logger.LogError(ex);
        throw ex;
    }

}
}  

When I try to execute it says

An attempt was made to access a socket in a way forbidden by its
access permissions 127.0.0.1:25

Please suggest me what should i do. I tried turning off the firewall as per some answers in the forums, but no luck.

Thank you in advance

  • 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-23T23:16:27+00:00Added an answer on May 23, 2026 at 11:16 pm

    for your code to work you need to have an SMTP server running on the local machine which accepts connections on 127.0.0.1, the exception implies that this either not the case or that some problem with priviliges and/or configuration exists.

    EDIT:
    Depending on your OS you could configure IIS to act as SMTP server. If you are on Windows 2008 then you need to use IIS 6 (contains SMTP server) additionally to IIS 7 (no SMTP server).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the code below to send messages via System.Net.Mail and am
I am trying to send an email via GMail from ASP.Net using the code
I am trying to use PEAR Mail to send from my gmail address using
I am trying to use the Appengine Mail API to send mail from my
The code below is what I am trying to use in order to get
I'm trying to use the code below, but it's not working: UPDATED WORKING: $(document).ready(function()
I am trying to use the below code to close the window. But getting
I am trying to use the code below to convert an integer in ax
I am trying to send email using the following method in my action class:
I'm trying to use BCC fields in some PHP email. My code is as

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.