I have a NET 2.0 aspx page on which I am trying to send the data the user entered. I am using the System.Net.Mail classes and the process of building the email mesage and sending it appear to work but the mail is not really being sent (at least it never arrives). On my old ASP.NET 1.1 pages I used "localhost" and I am trying the same with 2.0 as showhn here. Dim mailServerName As String = "localhost" Is this correct? What should I be using? Wayne ------------ Wayne
I am finally able to send emails from my NET 2.0 Beta pages. The big problem appears to have been the following lines of code: mailClient.UseDefaultCredentials = True mailClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis They were part of the sample code I found and was trying to adapt. After Googling around I found several issues with the whole "credentials" part of the process so I decided to remove those two lines and that fixed it. My working Sub is as follows: Public Sub SendMail(ByVal from As String, ByVal [to] As String, ByVal subject As String, ByVal body As String) Dim mailServerName As String = "localhost" Dim message As New MailMessage(from, [to], subject, body) Try message.IsBodyHtml = True Dim mailClient As New SmtpClient() mailClient.Host = mailServerName mailClient.Send(message) Catch ex As Exception lblInfo.Text = ex.Message lblInfo.Visible = True Finally message.Dispose() End Try End Sub ------------ Wayne