I have spent half a day trying to get this to work, I hope someone can help me out.
This is the code I am trying to run
Dim emailMessage As EmailMessage = New EmailMessage
emailMessage.FromAddress = New EmailAddress("myinternalemail@mycompany.com", "Charles Swann")
emailMessage.AddToAddress(New EmailAddress("myinternalemail@mycompany.com", "Odette de Crecy"))
emailMessage.Subject = "Missed you"
emailMessage.TextPart = New TextAttachment("Just checking where " & "you were last night." & Constants.vbCrLf & "Send me a note!" & Constants.vbCrLf & Constants.vbCrLf & "-Charles")
emailMessage.HtmlPart = New HtmlAttachment("<html><body>" & "<p>Just checking up on where you were last night.</p>" & Constants.vbCrLf & "<p>Send me a note!</p>" & Constants.vbCrLf & Constants.vbCrLf & "<p>-Charles</p></body></html>")
Dim oSmtpServer As SmtpServer = New SmtpServer("localhost")
emailMessage.Send(oSmtpServer)
I keep getting could not connect to (shows the ip address), when I trace it I get the error from the tcpip client that the software closed the connection.
If I use the following code using the same smtpserver
'Add the following code in a button click or link click
Dim mm As New Mail.MailMessage
mm.To = "jose.garcia@hbc.com"
mm.Cc = "jose.garcia@hbc.com"
mm.From = "jose.garcia@hbc.com"
mm.Subject = "Testing the Email through ASP.Net"
mm.BodyFormat = MailFormat.Html
mm.Body = "<h1>This is just a test mail. Looks like it passed</h1><br><table border='1'><tr><td>testing</td></tr></table>"
'Your ip address/ localweb server name
SmtpMail.SmtpServer.Insert(0, "localhost")
Try
SmtpMail.Send(mm)
Catch ex As Exception
Throw (ex)
End Try
All works fine.
I am not sure what I am missing with the use of this component.
Any ideas will be appreciated...
Thanks.
jmg.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you sure you have an SMTP server running on localhost? If you're getting a "could not connect" error, it's probably not running. If you are logging in to another machine, it could also mean that it's either a firewall or network problem.
An easy way to test it is to run telnet and log in to port 25, e.g. from a DOS prompt:
telnet localhost 25.
Cheers!
-Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have spent half a day trying to get this to work, I hope someone can help me out.
This is the code I am trying to run
Dim emailMessage As EmailMessage = New EmailMessage
emailMessage.FromAddress = New EmailAddress("myinternalemail@mycompany.com", "Charles Swann")
emailMessage.AddToAddress(New EmailAddress("myinternalemail@mycompany.com", "Odette de Crecy"))
emailMessage.Subject = "Missed you"
emailMessage.TextPart = New TextAttachment("Just checking where " & "you were last night." & Constants.vbCrLf & "Send me a note!" & Constants.vbCrLf & Constants.vbCrLf & "-Charles")
emailMessage.HtmlPart = New HtmlAttachment("<html><body>" & "<p>Just checking up on where you were last night.</p>" & Constants.vbCrLf & "<p>Send me a note!</p>" & Constants.vbCrLf & Constants.vbCrLf & "<p>-Charles</p></body></html>")
Dim oSmtpServer As SmtpServer = New SmtpServer("localhost")
emailMessage.Send(oSmtpServer)
I keep getting could not connect to (shows the ip address), when I trace it I get the error from the tcpip client that the software closed the connection.
If I use the following code using the same smtpserver
'Add the following code in a button click or link click
Dim mm As New Mail.MailMessage
mm.To = "jose.garcia@hbc.com"
mm.Cc = "jose.garcia@hbc.com"
mm.From = "jose.garcia@hbc.com"
mm.Subject = "Testing the Email through ASP.Net"
mm.BodyFormat = MailFormat.Html
mm.Body = "<h1>This is just a test mail. Looks like it passed</h1><br><table border='1'><tr><td>testing</td></tr></table>"
'Your ip address/ localweb server name
SmtpMail.SmtpServer.Insert(0, "localhost")
Try
SmtpMail.Send(mm)
Catch ex As Exception
Throw (ex)
End Try
All works fine.
I am not sure what I am missing with the use of this component.
Any ideas will be appreciated...
Thanks.
jmg.
Hi-
Are you sure you have an SMTP server running on localhost? If you're getting a "could not connect" error, it's probably not running. If you are logging in to another machine, it could also mean that it's either a firewall or network problem.
An easy way to test it is to run telnet and log in to port 25, e.g. from a DOS prompt:
telnet localhost 25.
Cheers!
-Mike