troubleshooting Question

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

Avatar of brasso_42
brasso_42 asked on
ASPASP.NET
4 Comments3 Solutions422 ViewsLast Modified:
Hi

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

Thanks

Brasso

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <p>
      From:<br />
      <asp:TextBox ID="txtFromAddress" runat="server" Columns="35" /></p>
    <p>
      To:<br />
      <asp:TextBox ID="txtToAddress" runat="server" Columns="35" /></p>
    <p>
      Subject:<br />
      <asp:TextBox ID="txtSubject" runat="server" Columns="50" /></p>
    <p>
      Body:<br />
      <asp:TextBox ID="txtBody" runat="server" Columns="75" TextMode="MultiLine" Rows="6" /></p>
    <p>
      <asp:Button ID="btnSend" runat="server" Text="Send Mail" /></p>
  </div>
  </form>
</body>
</html>


VB COde

   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()

        smtpClient.Send(mailMessage)
       
    End Sub

Web.config settigns

  <system.net>
    <mailSettings>
      <smtp from="">
        <network host="192.168.17.1" password="" userName="" />
      </smtp>
    </mailSettings>
  </system.net>
ASKER CERTIFIED SOLUTION
Dustin Hopkins
Senior Web Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros