Asp.net 2.0

DocMod

Guppy
Hi, is there something that I need to have setup to send email from a .aspx page using .net 2.0? I set up web.config as such:
<system.net>
<mailSettings>
<smtp>
<network
host="mail.domain.com"
port="25"
userName="[email protected]"
password="pswd" />
</smtp>
</mailSettings>
</system.net>

And I have the following in my code behind class:

Dim message As New MailMessage("myemail", theiremail)
message.Subject = "subject"
message.Priority = MailPriority.High
message.Body = Body
message.IsBodyHtml = False
Dim MailClient As New SmtpClient
MailClient.Send(message)
message.Dispose()

This is on a button click event and when I test I get nothing. Can any one help? Thx
 
I can't say I know the answer but I have successfully used those classes but not using a config file and maybe not an authenticated server.

As in most problems, you really need to narrow it down by eliminating things until it works :) That might not solve the problem but it will point you in the right direction..

I suggest first trying it purely in code. ie set the SmtpClient's host property and then its Credentials property to

new System.Net.NetworkCredential(user, pwd)

For another test, do you have access to an Smtp server that doesn't require authentication? Any mail server (eg your ISP's MX) will probably accept mail for its local domain without authentication. I guess spam filtering may sometimes get in the way of that these days.

Cheers
Ross
 
Thanks for the replies. As I went through my code I found that the problem was not the email function it was another function that had to run sucessfully before the email was sent. I wrote the code quickly and didnt have exception handling in place yet.
 
Back
Top