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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:06:31+00:00 2026-06-04T11:06:31+00:00

I am using this code for sending email in asp.net: Using System.Net.Mail public string

  • 0

I am using this code for sending email in asp.net:

Using System.Net.Mail

public string SendEmail()
{
    SmtpClient obj = new SmtpClient();
    MailMessage Mailmsg = new MailMessage();
    Mailmsg.To.Clear();

    Recievers = new MailAddressCollection();
    Recievers.Add(txtToAddress.Text);
    SenderName = "Info";
    SenderEmail = txtFromAddress.Text;
    Subject = "subj";
    Body = "body";
    UseBcc = false;

    if (UseBcc)
    {
        foreach (MailAddress RecieverItem in Recievers)
        {
            Mailmsg.Bcc.Add(RecieverItem);
        }
    }
    else
    {
        foreach (MailAddress RecieverItem in Recievers)
        {
            Mailmsg.To.Add(RecieverItem);
        }
    }

    Mailmsg.From = new MailAddress(SenderEmail, SenderName, System.Text.Encoding.UTF8);
    Mailmsg.Subject = Subject;
    Mailmsg.SubjectEncoding = Encoding.UTF8;
    Mailmsg.BodyEncoding = System.Text.Encoding.UTF8;
    Mailmsg.IsBodyHtml = false;

    obj.Host = mail.domain.com;

    System.Net.NetworkCredential BasicAuthenticationInfo = new System.Net.NetworkCredential("info@domain.com", "password");

    obj.UseDefaultCredentials = false;
    obj.Credentials = BasicAuthenticationInfo;

    Mailmsg.Body = Body;
    Mailmsg.IsBodyHtml = true;
    try
    {
        obj.Send(Mailmsg);
        return "sent";
    }
    catch (Exception ex)
    {
        return ex.ToString();
    }
}

It correctly sends emails to recievers which are defined in my domain (like mail@domain.com), but I cannot send email to other mail servers (like mail@yahoo.com).

What is wrong in my code?

(May it relate to SmtpClient properties? I have set smtpclient.host to mail.mydomain.com
and use username and password of one of my mail accounts which are defined in my domain)

Thanks

  • 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-06-04T11:06:33+00:00Added an answer on June 4, 2026 at 11:06 am

    It must be something related to your exchange server. there are transport rules in exchange which define how you can communicate with the outside world.

    http://www.msexchange.org/articles_tutorials/exchange-server-2007/management-administration/restricting-users-send-receive-external-messages-exchange-server-2007.html

    you must be getting some exception while sending email to outside network

    System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.1.1 User unknown
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
    

    If this is error you are getting this mean your exchange is not supported to send email directly to outside network. as I am no MS exchange expert but i have been using a exchange server configured in my network that can’t send email to outside network but we enable email forwarding to contacts.

    May be this can help you. http://www.petri.co.il/configuring-exchange-2007-send-connectors.htm

    also i would suggest you share this problem on https://serverfault.com/

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

Sidebar

Related Questions

Possible Duplicate: Send email using System.Net.Mail through gmail. (C#) I am using this code
I'm using the following code from this answer Sending email in .NET through Gmail
I am using MFMailComposeViewController for sending the Email, With this code I am able
Whats wrong with this code which is sending last email row twice? Using yii
I am using ASP.NET Web forms and sending an automated email through our SMTP
I am using the following very simple code and I keep getting System.Net.Mail.SmtpException failure
I am sending email using asp.net and it is working fine. But when an
While using this code to serialize an object: public object Clone() { var serializer
In ASP.NET I am sending a MailMessage but it won't go through. The code
I'm using http://code.google.com/p/django-email-extras/ to generate rich email content. I have trouble in sending email

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.