472,126 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

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 6480
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.