Reputation: 113
So I have an asp.net server running on discountasp.net and for whatever reason when I just published the new version of the website it stopped sending emails. I tried changing the code back to exactly how it was done in the old website and it didn't work. I've tried many other solutions to no avail. Here's the old code:
Dim message As New MailMessage
message.IsBodyHtml = True
message.From = New MailAddress("[email protected]", "[email protected]")
If Me.ddlSendTo.SelectedValue = 1 Then
message.To.Add(New MailAddress("[email protected]"))
message.Subject = "Sales Inquiry From mydomain.com"
ElseIf Me.ddlSendTo.SelectedValue = 2 Then
message.To.Add(New MailAddress("[email protected]"))
message.Subject = "Support Question From mydomain.com"
End If
Dim sb As New StringBuilder()
sb.Append("The following message was sent from a user of our website as a request for more information.<br/><br/>")
sb.Append("Here is the message they sent:<br/><br/>")
sb.Append("Sender's Name: " & Me.txtSenderName.Text & "<br/>")
sb.Append("Senders Email: <a href='mailto:" & Me.txtSenderEmail.Text & "'>" & Me.txtSenderEmail.Text & "</a><br/>")
sb.Append("Company Name: " & Me.txtCompany.Text & "<br/>")
sb.Append("Phone Number: " & Me.txtPhone.Text & "<br/><br/>")
sb.Append("Subject: " & Me.txtSubject.Text & "<br/>")
sb.Append("Message: " & Me.txtEmailMsg.Text)
message.Body = sb.ToString()
Try
Dim client As New SmtpClient()
client.Host = "localhost"
client.Send(message)
Catch ex As SmtpException
Me.errors.InnerHtml = ex.Message & " local host message"
Return
End Try
Here's my current iteration that is still not working:
Dim toEmail As String
Dim subject As String
If Me.ddlSendTo.SelectedValue = 1 Then
If isTesting() Then
toEmail = GetTesterEmail()
Else
toEmail = "[email protected]"
End If
subject = "Sales Inquiry From MyDomain.com"
ElseIf Me.ddlSendTo.SelectedValue = 2 Then
If isTesting() Then
toEmail = GetTesterEmail()
Else
toEmail = "[email protected]"
End If
subject = "Support Question From MyDomain.com"
End If
Dim sb As New StringBuilder()
sb.Append("The following message was sent from a user of our website as a request for more information.<br/><br/>")
sb.Append("Here Is the message they sent:<br/><br/>")
sb.Append("Sender's Name: " & Me.txtName.Value & "<br/>")
sb.Append("Senders Email: <a href='mailto:" & Me.txtEmail.Value & "'>" & Me.txtEmail.Value & "</a><br/>")
sb.Append("Company Name: " & Me.txtCompany.Value & "<br/>")
sb.Append("Phone Number: " & Me.txtPhone.Value & "<br/><br/>")
sb.Append("Subject: " & Me.txtSubject.Value & "<br/>")
sb.Append("Message: " & Me.txtMessage.Value)
'message.Body = sb.ToString()
Dim message As New MailMessage("[email protected]", toEmail, subject, sb.ToString())
message.IsBodyHtml = True
Try
Dim client As New SmtpClient()
client.Host = "smtp.mydomain.com"
client.Port = 25
client.Credentials = New System.Net.NetworkCredential("[email protected]", "password")
client.Send(message)
Catch ex As SmtpException
Me.errors.Text = ex.Message & " local host message"
Return
End Try
I tried leaving off network credentials, leaving off port, leaving off the @mydomain.com on the network credentials. Nothing works
Upvotes: 0
Views: 115