Mail Sending Failure on Main Server

Last post 05-20-2008 3:56 AM by yasserzaid. 9 replies.

Sort Posts:

  • Mail Sending Failure on Main Server

    05-16-2008, 2:10 AM

     Hello  EveryOne,

    SendMail function working on local server,

    But not on main server.

    Thanks In Advance 

  • Re: Mail Sending Failure on Main Server

    05-16-2008, 2:26 AM

    Hello,

    What type of error you received?

    Regards

  • Re: Mail Sending Failure on Main Server

    05-16-2008, 2:37 AM
    • Loading...
    • Dotnetfreaks
    • Joined on 05-15-2008, 4:56 AM
    • Delhi, India
    • Posts 16

    Hello, Which one namespace are using to send an email like System.web.mail or System.net Mail......?

    May be your SMTP server required authentication means Username and password to send a mail.....

    well if you are working System.web.Mail.SMtpMail class to send mail it should work bcs it's not need to authenticate on SMTP server.. if you are working on  System.net Mail then it's required authentication......

    Tell me which one class you are using and if feasible then paste your code.....  

    ---------------------------------------------------------------
    http://blogs.dotnetfreaks.net

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: Mail Sending Failure on Main Server

    05-16-2008, 2:49 AM

    thanks for reply,

    i am using this namespace. 

    using System.Net.Mail;

  • Re: Mail Sending Failure on Main Server

    05-16-2008, 3:01 AM

    check for SMTP server settings and authentication in main server
  • Re: Mail Sending Failure on Main Server

    05-16-2008, 3:11 AM
    • Loading...
    • Dotnetfreaks
    • Joined on 05-15-2008, 4:56 AM
    • Delhi, India
    • Posts 16

    Anand you need autheticate on SMTP server ....

                 MailMessage _mail = new MailMessage();

                  _mail.From = new MailAddress(senderEmailID, sendername);
                        _mail.To.Add(_toEmailID);
                        _mail.Subject = _mailsubjectsubject;
                        _mail.Body = _emailbody;
     

                    SmtpClient mailClient = new SmtpClient(ServerName,25);
                        _mail.Priority = MailPriority.Normal;
                        _mail.IsBodyHtml = _isHTMLBody;
                        mailClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                        mailClient.Credentials = new NetworkCredential(username, passwd);
                        mailClient.Send(_mail);

     

    try to use like this.......

     

    i hope your problem will solve....... 

    ---------------------------------------------------------------
    http://blogs.dotnetfreaks.net

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: Mail Sending Failure on Main Server

    05-16-2008, 3:21 AM

     Ok,

    But client is not being ready to give his network username and pwd 

  • Re: Mail Sending Failure on Main Server

    05-16-2008, 3:46 AM
    • Loading...
    • Dotnetfreaks
    • Joined on 05-15-2008, 4:56 AM
    • Delhi, India
    • Posts 16

     If client is not ready to share SMTP server details so you should use System.web.Mail namespace to send a mail.....it doesn't require any authentication......Cheers Yes
     

    ---------------------------------------------------------------
    http://blogs.dotnetfreaks.net

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: Mail Sending Failure on Main Server

    05-16-2008, 11:31 PM
    Hi,
    Let's back up a second. Anaand-- can you post the exception and the stack trace you are seeing?

    Cheers!
    Dave
  • Re: Mail Sending Failure on Main Server

    05-20-2008, 3:56 AM
    Answer

    Hi

    Try this

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Mail;
    
    public partial class SendEmail : System.Web.UI.Page
    {
    string strMailOrTel;
    
    protected void Page_Load(object sender, EventArgs e)
    {
    
    }
    private bool SendMail()
    {
    try
    {
    string strTo = "your email";
    string strFrom = txtFrom.Text;
    string strBody = txtMessage.Text ;
    string strSubject = txtSubject.Text ;
    SmtpMail.SmtpServer = ("your smtp");
    SmtpMail.Send(strFrom, strTo, strSubject, strBody);
    
    return true;
    }
    catch (Exception ex)
    {
    return false;
    }
    }
    
    protected void btn_Send_Click(object sender, EventArgs e)
    {
    bool TrueOrFalse = SendMail();
    if ((TrueOrFalse == true))
    {
    Response.Redirect("~/MailSent.aspx");
    }
    else
    {
    Label1.Text = "Try again";
    }
    
    }
    
    
    }
    
     
    Regards,
    Yasser Zaid

    ~ Please remember to click Mark as Answer on this post if it helped you ~
Page 1 of 1 (10 items)
Microsoft Communities
Page view counter