PaulR
PaulR

Reputation: 47

asp.net Setting up email

Alas, my experience has reached an end and request help. So far I've followed the instructions from this article https://web.archive.org/web/20211016215613/http://www.4guysfromrolla.com/webtech/080801-1.shtml . My only problem is It compiles fine but no email arrives. I have a feeling it's for obvious reasons which escape me.

This is my aspx.vb page.................................................................................................................

Imports System.Web.Mail

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

    Const ToAddress As String = "[email protected]"
    Dim objMM As New MailMessage("[email protected]", ToAddress)
    Dim smtp As New SmtpClient
    objMM.IsBodyHtml = False
    objMM.Priority = MailPriority.Normal
    objMM.Subject = "Hello there!"
    objMM.Body = "Hi!" & vbCrLf & vbCrLf & "How are you doing?"
    smtp.Send(objMM)
end sub

..........................................................................................................................................................

my aspx page contains the following ...w/o the parenthesis (<%@Import Namespace="System.Web.Mail" %>)

The web.config file is as follows(unfortunately it won't display with greater than less than symbols.

<configSections>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="relay-hosting.secureserver.net" port="25">
      </smtp>
    </mailSettings>
  </system.net>
</configSections>

The people at godaddy.com told me that the only information I needed was the relayServer host name which is relay-hosting.secureserver.net and username and password weren't required.

Thanks for any help

Upvotes: 1

Views: 1223

Answers (2)

Brian Smith
Brian Smith

Reputation: 367

I think that is your problem. Change the mail server port from port 80 to port 25 in the web.config

Try using this block of code:

Dim objMailMessage As New System.Net.Mail.MailMessage 

With objMailMessage 
    .IsBodyHtml = False 
    .From = New MailAddress("[email protected]")   
    .To.Add("[email protected]") .Subject = "Your Subject" 
    .Body = "Body Text" 
End With 

Dim objSMTPClient As New System.Net.Mail.SmtpClient("relay-hosting.secureserver.net", 25) 
objSMTPClient.Credentials = CredentialCache.DefaultNetworkCredentials
objSMTPClient.DeliveryMethod = SmtpDeliveryMethod.Network 
objSMTPClient.Send(objMailMessage)

Here is the thread and some other examples as well. It also sounds like there is a godaddy setting somewhere, but I don't remember having to change anything on my end.

http://forums.asp.net/t/939893.aspx

Upvotes: 2

Greg
Greg

Reputation: 16680

I think the problem is that you cannot send email from godaddy from addresses outside of your domain. try sending it from some registered email address on your domain.

Upvotes: 1

Related Questions