469,612 Members | 1,553 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

How to send mail on yahoo, hotmail

Hello All,

I want to send mail through asp.net to other my company domain e.g yahoo, hotmail etc
Code is as below

////Start Code////////
Expand|Select|Wrap|Line Numbers
  1. Imports System.Net.Mail
  2.  Dim MailMessage As MailMessage = New MailMessage
  3.  
  4.         MailMessage.From = New System.Net.Mail.MailAddress   ("DO_NOT_REPLY@QHSE.COM")
  5.  
  6.         MailMessage.To.Add(New MailAddress("abc@hotmail.com"))
  7.  
  8.         MailMessage.Subject = "Subject"
  9.  
  10.         MailMessage.Body = "Body"
  11.  
  12.         Dim SmtpClient As SmtpClient = New SmtpClient
  13.  
  14.         SmtpClient.Host = "es10" ' my email server
  15.         SmtpClient.Port = 25
  16.  
  17.         Try
  18.             SmtpClient.Send(MailMessage)
  19.  
  20.         Catch ex As Exception
  21.             Response.Write(ex.Message)
  22.         End Try
////////////End Code///

But it returns error message as below.

Transaction failed. The server response was: Relay rejected for policy reasons.

Note: when i send email to my company adress through this code it work properly.

Any one can help

Thanks
Jul 8 '09 #1
2 6310
Frinavale
9,735 Expert Mod 8TB
Is your mail server configured to allow outbound emails?
Jul 8 '09 #2
Curtis Rutland
3,256 Expert 2GB
I don't believe that Hotmail or Yahoo will let you use their relays.

You might try providing your login credentials to the SMTP server though. It may work.

Before I give you this code sample, I have to say that using a Class name for an instance name is just plain crazy. You made an SmtpClient object called SmtpClient. How do you know which you are referring to, the instance, or the class? Change the name to something else, like this maybe:

Expand|Select|Wrap|Line Numbers
  1. Dim MailServer As SmtpClient = New SmtpClient
  2. MailServer.Credentials = new System.Net.NetworkCredential("username", "password")
Jul 9 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by erdem kemer | last post: by
4 posts views Thread by PawelR | last post: by
5 posts views Thread by fanor | last post: by
3 posts views Thread by Dave | last post: by
reply views Thread by jlconde | last post: by
reply views Thread by Roba roro | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.