You must Sign In to post a response.
  • Category: ASP.NET

    Some issues in Send Mail

    Hi ,
    I am created a code and host it . but mail is sometime send but some mai id's did not sent the mail.i got confused.i cant able to find that problem .

    My code is below

    public void EmailSend(string frmID, string frmName, string toID, string subMsg, String BodyMsg, bool status)
    SmtpClient smtpclient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress("xxx", "xxx");
    smtpclient.Host = "";
    smtpclient.Port = 25;
    message.From = fromAddress;
    message.Subject = subMsg;
    message.Body = BodyMsg;
    message.BodyEncoding = System.Text.Encoding.ASCII;
    message.IsBodyHtml = status;
    message.Priority = MailPriority.High;
    NetworkCredential ocredential = new NetworkCredential("", "password");
    smtpclient.UseDefaultCredentials = true;
    smtpclient.Credentials = ocredential;
    catch { }

    so anyone please help me to i am solve this problem

    Thanks with
  • #764696


    In order to find the issue from your hosted code you may have to log the event, otherwise it is difficult to find the reason.

    Also make sure that your SMTP service is running fine. You may check application and system event log also to know if there was any error while sending email.

    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM

  • #764708
    Following are some of the tips for your issue.
    I think you trying to reproduce the issue, But could not.

    1. Are you using simple gmail server/ any other specific mail server?.
    2. If your hosting server is out of India(Different location from you development). You may face this issue.
    3. In the above case it your switching dev and hosing server with same email id. You may getting this issue.
    For Ex. Login to the US server and open your email id send email. Now login your local box and send email that time it will check, whether you are the correct person or hacker? In that case it may ask captcha.. That time you may not send email from your hosting server.
    The code
    SmtpClient smtpclient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress("xxx", "xxx");

    which you are trying is correct. But you have to check your mail setting and configure it as app compatible

    By Nathan
    Direction is important than speed

  • #764721
    Hai Paul,
    Are you sure that the email is sending to only particular email ids. Make sure that the email id's are valid and acceptable as per the uniform format.(
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #764728


    try assigning To and From address as follows:
    MailMessage mailMsg = new MailMessage();
    mailMsg.From =new MailAddress("");
    mailMsg.To.Add(new MailAddress(""));
    Hope it helps.
    Shashikant Gurav

  • #764770
    Friends thanks for all your valuable reply.

    May be i am find the error. The error is Mail send only with the following mails Gmail,Yahoo,Rediff etc.

    If mail id like any Particular id or anything like that na , i does mot throw any error but mail only not sent.

    This is My Problem.

    now you give solution as well as before.


  • #765049
    need to check the correct port id correct client and host domain for sending and receiving the emails

Sign In to post your comments