sending email not work?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: sending email not work?

  1. #1
    giit Guest

    sending email not work?


    I am using the MailMessage object to send e-mail.But it still not sending
    an email.

    Here is the code:
    I have refrenced <%@ Import Namespace="System.Web.Mail" %> file in my program.

    try
    {

    email = new MailMessage();
    email.From= mFrom;
    email.To = mTo;
    email.Subject = mSubject;
    email.Body = mBody;
    email.BodyFormat =mBodyFormat;
    email.Priority=MailPriority.High;
    SmtpMail.Send(email);
    mErrmsg="Success";
    }
    catch
    {
    mErrmsg = "Error Sending Message";
    }

    If I step through the above code it execute without error .But still when
    I check for the e-mail, I never receive it.Let me know what is wrong with
    the above code?

    So why I am not able to get the email which is sended by using above code.


    thanks,
    Geeta.

  2. #2
    Garland Frye Guest

    Re: sending email not work?

    Although I don't exactly know, perhaps it would be beneficial to check the
    settings of your Mail Server in IIS. The code looks valid!

    Thanks,
    Garland
    "giit" <giit@usa.net> wrote in message news:3baf7efc$1@news.devx.com...
    >
    > I am using the MailMessage object to send e-mail.But it still not

    sending
    > an email.
    >
    > Here is the code:
    > I have refrenced <%@ Import Namespace="System.Web.Mail" %> file in my

    program.
    >
    > try
    > {
    >
    > email = new MailMessage();
    > email.From= mFrom;
    > email.To = mTo;
    > email.Subject = mSubject;
    > email.Body = mBody;
    > email.BodyFormat =mBodyFormat;
    > email.Priority=MailPriority.High;
    > SmtpMail.Send(email);
    > mErrmsg="Success";
    > }
    > catch
    > {
    > mErrmsg = "Error Sending Message";
    > }
    >
    > If I step through the above code it execute without error .But still when
    > I check for the e-mail, I never receive it.Let me know what is wrong with
    > the above code?
    >
    > So why I am not able to get the email which is sended by using above code.
    >
    >
    > thanks,
    > Geeta.




  3. #3
    KraKheD Guest

    Re: sending email not work?


    "Garland Frye" <gfrye@ssts.com> wrote:
    >Although I don't exactly know, perhaps it would be beneficial to check the
    >settings of your Mail Server in IIS. The code looks valid!
    >
    >Thanks,
    >Garland
    >"giit" <giit@usa.net> wrote in message news:3baf7efc$1@news.devx.com...
    >>
    >> I am using the MailMessage object to send e-mail.But it still not

    >sending
    >> an email.
    >>
    >> Here is the code:
    >> I have refrenced <%@ Import Namespace="System.Web.Mail" %> file in my

    >program.
    >>
    >> try
    >> {
    >>
    >> email = new MailMessage();
    >> email.From= mFrom;
    >> email.To = mTo;
    >> email.Subject = mSubject;
    >> email.Body = mBody;
    >> email.BodyFormat =mBodyFormat;
    >> email.Priority=MailPriority.High;
    >> SmtpMail.Send(email);
    >> mErrmsg="Success";
    >> }
    >> catch
    >> {
    >> mErrmsg = "Error Sending Message";
    >> }
    >>
    >> If I step through the above code it execute without error .But still when
    >> I check for the e-mail, I never receive it.Let me know what is wrong with
    >> the above code?
    >>
    >> So why I am not able to get the email which is sended by using above code.
    >>
    >>
    >> thanks,
    >> Geeta.

    >
    >


    The code looks accurate, but.....

    The reason for the anomaly is probably because the server processing the
    application is unable to send the mail, i.e. SMTP services are not started
    OR there is no mail software installed.

    A simple fix:

    SmtpMail.SmtpServer = "MyMailServer";
    SmtpMail.Send(email);


    This SHOULD resolve the problem.

    Hope that helps!




  4. #4
    KraKheD Guest

    Re: sending email not work?


    "giit" <giit@usa.net> wrote:
    >
    > I am using the MailMessage object to send e-mail.But it still not sending
    >an email.
    >
    >Here is the code:
    >I have refrenced <%@ Import Namespace="System.Web.Mail" %> file in my program.
    >
    > try
    > {
    >
    > email = new MailMessage();
    > email.From= mFrom;
    > email.To = mTo;
    > email.Subject = mSubject;
    > email.Body = mBody;
    > email.BodyFormat =mBodyFormat;
    > email.Priority=MailPriority.High;
    > SmtpMail.Send(email);
    > mErrmsg="Success";
    > }
    > catch
    > {
    > mErrmsg = "Error Sending Message";
    > }
    >
    >If I step through the above code it execute without error .But still when
    >I check for the e-mail, I never receive it.Let me know what is wrong with
    >the above code?
    >
    >So why I am not able to get the email which is sended by using above code.
    >
    >
    >thanks,
    >Geeta.


    The code looks accurate, but.....

    The reason for the anomaly is probably because the server processing the
    application is unable to send the mail, i.e. SMTP services are not started
    OR there is no mail software installed.

    A simple fix:

    SmtpMail.SmtpServer = "MyMailServer";
    SmtpMail.Send(email);


    This SHOULD resolve the problem.

    Hope that helps!



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center