Me too. Very tired of trying to resolve this issue. Any words of wisdom? I've tried using different port numbers. I've tried using different host names/strings. I've tried miles and miles of code. Currently using some code I picked up somewhere in this forum called MailHelper. Also, forgive me if this is a totally stupid question, but in the Web.config file I included my username and password. Isn't that a big security no-no? What's protecting that info?
Anyway... here's my Web.config mail settings:
<
mailSettings>
<
smtp from="me@mydomain.com">
<
network host="relay-hosting.secureserver.net" port="3535" userName="me@mydomain.com" password="*******"/>
</
smtp>
</
mailSettings>
This code is in my App_Code folder:
Imports
System.Net.Mail
Public
Class MailHelper
''' <summary>
''' Sends an mail message
''' </summary>
''' <param name="from">Sender address</param>
''' <param name="recipient">Recipient address</param>
''' <param name="bcc">Bcc recipient</param>
''' <param name="cc">Cc recipient</param>
''' <param name="subject">Subject of mail message</param>
''' <param name="body">Body of mail message</param>
Public Shared Sub SendMailMessage(ByVal from As String, ByVal recipient As String, _
ByVal subject As String, ByVal body As String)
' Instantiate a new instance of MailMessage
Dim mMailMessage As New MailMessage()
' Set the sender address of the mail message
mMailMessage.From =
New MailAddress(from)
' Set the recepient address of the mail message
mMailMessage.To.Add(
New MailAddress(recipient))
' Check if the bcc value is null or an empty string
'If Not bcc Is Nothing And bcc <> String.Empty Then
' ' Set the Bcc address of the mail message
' mMailMessage.Bcc.Add(New MailAddress(bcc))
' End If
' Check if the cc value is null or an empty value
'If Not cc Is Nothing And cc <> String.Empty Then
' ' Set the CC address of the mail message
' mMailMessage.CC.Add(New MailAddress(cc))
' End If
' Set the subject of the mail message
mMailMessage.Subject = subject
' Set the body of the mail message
mMailMessage.Body = body
' Secify the format of the body as HTML
mMailMessage.IsBodyHtml =
True
' Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.Normal
' Instantiate a new instance of SmtpClient
Dim mSmtpClient As New SmtpClient()
' Send the mail message
mSmtpClient.Send(mMailMessage)
End Sub
End
Class
And this is the vb that makes the button work that's supposed to send the mail:
Imports
system.net.mail
Partial
Class SendMail7
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
MailHelper.SendMailMessage(
"me@mydomain.com", "me@mydomain.com", "Sample Subject", "Sample body of text for mail message")
End Sub
End
Class
'''''''''''''''''''''''''''''''''
I end up with an SMPTException, Failure to send mail, Inner Exception, bla, bla, bla...
Someone, anyone? Please help me?