sending email using IIS smtp service RRS feed

  • Question

  • User1025432697 posted

     I am working on an email that someone will send from one of our main sites requesting an account password.  I am using System.Net.Mail.MailMessage to create the email and then sending it using System.Net.Mail.SmtpClient.  Below is my code: 

    	Public Function sendEmail(ByVal address As String) As String
    		Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
    		mailMessage.To.Add(New System.Net.Mail.MailAddress("emailAddress"))
    		mailMessage.From = (New System.Net.Mail.MailAddress(address))
    		Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
    		Catch ex As Exception
    			Throw New ApplicationException("Data Error", ex)
    		End Try
    	End Function
    	Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    	End Sub

    Then in my web.config file I have the following

    				<network host="cook.CMAP.public" port="25" 
    It all looks like it is right but it is not working.  Any suggestions or pointers would be greatly appriciated.
    Richard Krell
    Chicago Metropolitan Agency for Planning

    Monday, September 20, 2010 3:13 PM

All replies

  • User197322208 posted

    1. put something in body and subject ( like "hello world" ;-))

    2. what do you mean by

     but it is not working.
    ? Did not throw any error ?

    Monday, September 20, 2010 10:18 PM
  • User1025432697 posted

    Maybe it is working but I am just not aware of it.  the whole point of this is for a user to visit one of our agencies web sites and they want to open an account.  So they do what so many do these days by just subitting their email address.  Once the user types that in and sends it, it is suppose to hit our site and grab a random password and reply to that users email address with that temp password and a link for the user to follow to change the temporaray password into something they can remember plus then they would also fill out their profile.

    So,  I have written a function that will accept the user email address and then  will send that to a yet to be defined email address here at our site.  It all looks right but it seems to be getting hungup in our IIS Smtp queue.  At least I have traced it to that poing thus far.  Do you think it would be better to hit our Exchange site.  I hadn't tried that because that didn't seem as safe as just hitting our IIS.

    Wednesday, September 22, 2010 12:46 PM
  • User-952121411 posted

    Do you think it would be better to hit our Exchange site. 

    I would say Yes but am not an expert on this.  I always use the Exchange SMTP server for outgoing mail and it seems to work well.

    I will say at this point you might need to look to another forum for IIS SMTP or Exchange issues.  If you are not getting a .NET exception or having trouble with the VB.NET code, then this forum is not the best place for server related issues.  For those questions, you might want to repost at either of the following (2) forums:

    IIS Forums:


    Exchange Server Forums:


    Friday, October 8, 2010 4:47 PM
  • User1122355199 posted

    Did you check the SMTP access settings to make sure you have appropriate permissions and that the IP address is not blocked.  What about firewall settings? 

    Friday, October 8, 2010 8:57 PM