[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-12-24
4
Medium Priority
?
397 Views
Last Modified: 2012-05-08
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>

Open in new window

0
Comment
Question by:brasso_42
4 Comments
 
LVL 3

Assisted Solution

by:crshekharam
crshekharam earned 664 total points
ID: 26121365
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
0
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 668 total points
ID: 26122036
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 http://bytes.com/topic/asp-net/answers/665140-sending-email-vb-net-via-exchange-server-2007-a#post2646497

Hope this helps,
Dustin
0
 
LVL 2

Assisted Solution

by:shrinivasmw
shrinivasmw earned 668 total points
ID: 26129874
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.
0
 
LVL 1

Author Comment

by:brasso_42
ID: 26137446
Hi

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

Brasso
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

830 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