ASP.NET Send E-Mail Via Exchange 2007 Relay IP

Posted on 2009-12-24
Last Modified: 2012-05-08

Im trying to send an e-mail via out Exchange 2007 server, but I get an error saying that it cant send.  If I change the IP to an exchange 2003 server it works fine.

I know the relay is setup properly on my 2007 server as I use it for another app I wrote using access 2007.

The Code Im using is below



Form Code

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm5.aspx.vb" Inherits="Blaze_Billz.WebForm5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head runat="server">




  <form id="form1" runat="server">



      From:<br />

      <asp:TextBox ID="txtFromAddress" runat="server" Columns="35" /></p>


      To:<br />

      <asp:TextBox ID="txtToAddress" runat="server" Columns="35" /></p>


      Subject:<br />

      <asp:TextBox ID="txtSubject" runat="server" Columns="50" /></p>


      Body:<br />

      <asp:TextBox ID="txtBody" runat="server" Columns="75" TextMode="MultiLine" Rows="6" /></p>


      <asp:Button ID="btnSend" runat="server" Text="Send Mail" /></p>






   Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSend.Click

        Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()

        mailMessage.From = New System.Net.Mail.MailAddress(txtFromAddress.Text.Trim())

        mailMessage.To.Add(New System.Net.Mail.MailAddress(txtToAddress.Text.Trim()))

        mailMessage.Priority = Net.Mail.MailPriority.High

        mailMessage.Subject = txtSubject.Text.Trim()

        mailMessage.Body = txtBody.Text.Trim()

        Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()



    End Sub

Web.config settigns



      <smtp from="">

        <network host="" password="" userName="" />




Open in new window

Question by:brasso_42
    LVL 3

    Assisted Solution

    Is there any user name and password required to authenticate the smtp server. And also try changing from address to the address with which it is intended to send
    LVL 14

    Accepted Solution

    Does the 2007 server relay restrict email sent from it based on the originating ip(webserver)?
    Also what is the actual error? This might help

    Hope this helps,
    LVL 2

    Assisted Solution

    On your SMTP server please check whether you have added your that server IP address in RELAY IP addresses list. So that SMTP server will allow you to send email messages from that SMTP.

    Let me know if this works or not.
    LVL 1

    Author Comment


    After some more testing it works fine if I use basic authentication.  It seems a bit buggy, but it will do as is for now.

    Thanks for your help


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now