asp.net : c#.net : difficulty in sending emails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vishalgupta
    New Member
    • Jun 2007
    • 47

    asp.net : c#.net : difficulty in sending emails

    when i use the code :
    [code=cpp]
    private void Report(int var)
    {
    var++;
    String ToEmail = "";
    String FromEmail = "";
    String Bdy = "";
    ToEmail = System.Configur ation.Configura tionManager.App Settings["EmailRepor tTo"];
    FromEmail = System.Configur ation.Configura tionManager.App Settings["EmailReportFro m"];
    Bdy = var.ToString();
    try
    {
    SmtpMail.Send(F romEmail, ToEmail,"value" ,Bdy);
    Response.Write( "Your Email has been sent sucessfully");
    }
    catch (Exception exc)
    {
    Response.Write( "Send failure: " + exc.ToString()) ;
    }
    }
    [/code]

    the output shows that the email has been send but no email is received on the ToEmail address

    when i use :
    [code=cpp]

    private void Report(int var)
    {
    var++;
    String ToEmail = "";
    String FromEmail = "";
    String Bdy = "";
    String ServerName = "";
    ServerName = System.Configur ation.Configura tionManager.App Settings["SMTPServerName "];
    ToEmail = System.Configur ation.Configura tionManager.App Settings["EmailRepor tTo"];
    FromEmail = System.Configur ation.Configura tionManager.App Settings["EmailReportFro m"];
    Bdy = var.ToString() ;
    System.Net.Mail .MailMessage message = new System.Net.Mail .MailMessage();
    message.To.Add( ToEmail);
    System.Net.Mail .MailAddress address = new System.Net.Mail .MailAddress(Fr omEmail);
    message.From = address;
    message.Subject = "value";
    message.Body = Bdy;
    System.Net.Mail .SmtpClient smtp = new System.Net.Mail .SmtpClient(Ser verName);
    smtp.Port = 25;
    try
    {
    smtp.Send(messa ge);
    Response.Write( "Your Email has been sent sucessfully");
    }
    catch (Exception exc)
    {
    Response.Write( "Send failure: " + exc.ToString()) ;
    }

    }

    [/code]

    it shows the exception :
    Send failure: System.Net.Mail .SmtpFailedReci pientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for vishal@yahoo.co .in at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender, MailAddressColl ection recipients, String deliveryNotify, SmtpFailedRecip ientException& exception) at System.Net.Mail .SmtpClient.Sen d(MailMessage message) at _Default.Report SpamBot(Int32 var)

    somebody please help as to how should i send the emails??
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    It sounds like Yahoo is viewing the email you are sending as SPAM. Yahoo then returns an email telling you that the mailbox in unavailable. Try turning off SPAM control in Yahoo and try sending again.

    Nathan

    Comment

    • vishalgupta
      New Member
      • Jun 2007
      • 47

      #3
      i ried sending to gmail too but the mails do not reach..

      if my code is right then why are the mails not reaching any of the specified email addresses....

      Comment

      Working...