Sending email through asp.net web app

Discussion in 'ASP .Net' started by MOHSEN KASHANI, Dec 13, 2007.

  1. Hi,
    I am working on an intranet web application and need to be able to send
    email through the application. I have to use an Exchange server to do this.
    Can you tell me what I need to set up, what information I need to have or
    collect?

    Thanks.
    MOHSEN KASHANI, Dec 13, 2007
    #1
    1. Advertising

  2. MOHSEN KASHANI

    Braulio Diez Guest

    Hi,

    First of all speak with the network administrator and ask for an SMTP
    server to rely on and send e-mails, problably he will give you an address,
    user and password, check with a telnet if it's working fine:

    http://msexchangeteam.com/archive/2006/07/14/428324.aspx

    Once you have checked that the account is working fine, you can code the
    ..net code, use system.net.mail namespace:

    http://www.systemnetmail.com/

    More info about how to send e-mails on .net:

    http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0

    Good luck
    Braulio



    /// ------------------------------
    /// Braulio Diez
    ///
    /// http://www.tipsdotnet.com
    /// ------------------------------




    "MOHSEN KASHANI" wrote:

    > Hi,
    > I am working on an intranet web application and need to be able to send
    > email through the application. I have to use an Exchange server to do this.
    > Can you tell me what I need to set up, what information I need to have or
    > collect?
    >
    > Thanks.
    >
    >
    >
    Braulio Diez, Dec 13, 2007
    #2
    1. Advertising

  3. "MOHSEN KASHANI" <> wrote in message
    news:...

    > I am working on an intranet web application and need to be able to send
    > email through the application. I have to use an Exchange server to do
    > this.
    > Can you tell me what I need to set up, what information I need to have or
    > collect?


    http://geekswithblogs.net/cubeberg/articles/78704.aspx


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Dec 13, 2007
    #3
  4. MOHSEN KASHANI

    Guest

    On Dec 13, 3:48 am, Braulio Diez <> wrote:
    > Hi,
    >
    > First of all speak with the network administrator and ask for an SMTP
    > server to rely on and send e-mails, problably he will give you an address,
    > user and password, check with a telnet if it's working fine:
    >
    > http://msexchangeteam.com/archive/2006/07/14/428324.aspx
    >
    > Once you have checked that the account is working fine, you can code the
    > .net code, use system.net.mail namespace:
    >
    > http://www.systemnetmail.com/
    >
    > More info about how to send e-mails on .net:
    >
    > http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0
    >
    > Good luck
    > Braulio
    >
    > /// ------------------------------
    > /// Braulio Diez
    > ///
    > ///http://www.tipsdotnet.com
    > /// ------------------------------
    >
    >
    >
    > "MOHSEN KASHANI" wrote:
    > > Hi,
    > > I am working on an intranet web application and need to be able to send
    > > email through the application. I have to use an Exchange server to do this.
    > > Can you tell me what I need to set up, what information I need to have or
    > > collect?

    >
    > > Thanks.- Hide quoted text -

    >
    > - Show quoted text -


    Thanks for the reply Braulio. I conatcted the administrator and was
    given the mail server name. I was told I do not require user id and
    password. So, in my web.config I added:
    <system.net>
    <mailSettings>
    <smtp>
    <network host="mailrelay.agencyname.gov" />
    </smtp>
    </mailSettings>
    </system.net>

    and in the aspx file:

    protected void Button1_Click(object sender, EventArgs e)
    {
    string strFrom = "";
    string strTo = "";
    MailMessage mm = new MailMessage(strFrom, strTo);
    mm.Subject = "Test Email from ASP.NET";
    mm.Body = "This is a test email sent from within an ASP
    application.";
    mm.IsBodyHtml = false;
    mm.Priority = MailPriority.Normal;
    SmtpClint sc = new SmtpClient();
    // SmtpClient sc = new SmtpClient("mailrelay.agencyname.gov");
    // sc.Credentials = new NetworkCredential();
    sc.Send(mm);
    }

    I get an error from Symantec Email Proxy:

    Your email message to
    with mail subject of
    Test Email from ASP.NET
    was unable to be sent because the connection to your mail server was
    interrupted.
    Please open your email client and re-send the message from the Send
    Message folder.

    I tried changing the web.config to read:
    <network host="mailrelay.agencyname.gov" userName="" password="" />
    but got the same error.

    Thanks.
    , Dec 13, 2007
    #4
  5. MOHSEN KASHANI

    Guest

    On Dec 13, 3:00 pm, wrote:
    > On Dec 13, 3:48 am, Braulio Diez <> wrote:
    >
    >
    >
    >
    >
    > > Hi,

    >
    > > First of all speak with the network administrator and ask for an SMTP
    > > server to rely on and send e-mails, problably he will give you an address,
    > > user and password, check with a telnet if it's working fine:

    >
    > >http://msexchangeteam.com/archive/2006/07/14/428324.aspx

    >
    > > Once you have checked that the account is working fine, you can code the
    > > .net code, use system.net.mail namespace:

    >
    > >http://www.systemnetmail.com/

    >
    > > More info about how to send e-mails on .net:

    >
    > >http://www.tipsdotnet.com/ArticleBlog.aspx?KWID=45&Area=SMTP&PageIndex=0

    >
    > > Good luck
    > > Braulio

    >
    > > /// ------------------------------
    > > /// Braulio Diez
    > > ///
    > > ///http://www.tipsdotnet.com
    > > /// ------------------------------

    >
    > > "MOHSEN KASHANI" wrote:
    > > > Hi,
    > > > I am working on an intranet web application and need to be able to send
    > > > email through the application. I have to use an Exchange server to do this.
    > > > Can you tell me what I need to set up, what information I need to have or
    > > > collect?

    >
    > > > Thanks.- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Thanks for the reply Braulio. I conatcted the administrator and was
    > given the mail server name. I was told I do not require user id and
    > password. So, in my web.config I added:
    > <system.net>
    > <mailSettings>
    > <smtp>
    > <network host="mailrelay.agencyname.gov" />
    > </smtp>
    > </mailSettings>
    > </system.net>
    >
    > and in the aspx file:
    >
    > protected void Button1_Click(object sender, EventArgs e)
    > {
    > string strFrom = "";
    > string strTo = "";
    > MailMessage mm = new MailMessage(strFrom, strTo);
    > mm.Subject = "Test Email from ASP.NET";
    > mm.Body = "This is a test email sent from within an ASP
    > application.";
    > mm.IsBodyHtml = false;
    > mm.Priority = MailPriority.Normal;
    > SmtpClint sc = new SmtpClient();
    > // SmtpClient sc = new SmtpClient("mailrelay.agencyname.gov");
    > // sc.Credentials = new NetworkCredential();
    > sc.Send(mm);
    > }
    >
    > I get an error from Symantec Email Proxy:
    >
    > Your email message to
    > with mail subject of
    > Test Email from ASP.NET
    > was unable to be sent because the connection to your mail server was
    > interrupted.
    > Please open your email client and re-send the message from the Send
    > Message folder.
    >
    > I tried changing the web.config to read:
    > <network host="mailrelay.agencyname.gov" userName="" password="" />
    > but got the same error.
    >
    > Thanks.- Hide quoted text -
    >
    > - Show quoted text -


    OK, I got it.
    I was testing this from my workstation and I already had setup an SMTP
    server (from within Outlook) and when I tried to use the other SMTP
    server (mailrealy...., given to me by administrator) from within the
    application, it choked. If I use the same SMTP server as listed in
    Outlook, it works fine. Thank you all for your suggestions and help.
    , Dec 14, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    3
    Views:
    3,754
    VB Programmer
    Aug 9, 2004
  2. John Abel

    Sending Through ^] Through telnetlib

    John Abel, Jan 23, 2004, in forum: Python
    Replies:
    2
    Views:
    343
  3. Mahrt, Dallas

    RE: Sending Through ^] Through telnetlib

    Mahrt, Dallas, Jan 23, 2004, in forum: Python
    Replies:
    0
    Views:
    500
    Mahrt, Dallas
    Jan 23, 2004
  4. rambabu
    Replies:
    0
    Views:
    387
    rambabu
    Mar 7, 2007
  5. Luke
    Replies:
    2
    Views:
    4,675
    Nigel Wade
    Mar 15, 2007
Loading...

Share This Page