email message in vb.net but I got this error

Posted by Sekar.C under VB.NET on 3/14/2012 | Points: 10 | Views : 1271 | Status : [Member] | Replies : 5
hi,
I use this code for email message in vb.net but I got this error
The transport failed to connect to the server. How to solve

Dim EmailTo As String     'Emailaddres for user to send
Dim EmailFrom As String 'Emailaddres for user from
Dim MailSubject As String 'Subject of Mail
Dim MessageBody As String 'Message
Dim ServerName As String 'Server Name - important


ServerName = "spiro47"
'Similarly, add in EmailTo, EmailFrom etc parameters here
EmailTo = "sekar.mca2009@gmail.com"
EmailFrom = "raja.mca2010@yahoo.com"
MailSubject = "welcome"
MessageBody = "hi"

'Set the SMTP Server's address
SmtpMail.SmtpServer = ServerName
Try
SmtpMail.Send(EmailFrom, EmailTo, MailSubject, MessageBody)
Catch ex As Exception
MsgBox("Delivery Failure: " & ex.Source & ex.Message)
End Try

regads
sekar.c

Regards
Sekar.c



Responses

Posted by: Sksamantaray on: 3/14/2012 [Member] Silver | Points: 25

Up
0
Down
I think your server name is wrong or your smtp is not properly set.
Try to write
ServerName = "127.0.0.1"
or
ServerName = "Localhost"

Let me know if it works for you

Thanks,
Sanjay

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sekar.C on: 3/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
i use local host name but got this error
The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for sath1983@gmail.com


Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/14/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Sekar,

Check your SMTP settings>>Access>> relay section, wheather 127.0.0.1 is added or not.
If not Add it and then try.

Thanks,
Sanjay

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 3/14/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Sekar,

Check your SMTP settings>>Access>> relay section, whether 127.0.0.1 is added or not.
If not Add it and then try.

Thanks,
Sanjay

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sekar.C on: 3/14/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
any other code for send message to email in vb.net

Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response