Connecting Tech Pros Worldwide Help | Site Map

How to send mail on yahoo, hotmail

  #1  
Old July 8th, 2009, 07:27 AM
Member
 
Join Date: Feb 2007
Posts: 53
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

Last edited by Frinavale; July 8th, 2009 at 02:52 PM. Reason: Added code tags. Please post code in [code] [/code] tags.
  #2  
Old July 8th, 2009, 02:54 PM
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North :)
Posts: 4,940
Provided Answers: 8

re: How to send mail on yahoo, hotmail


Is your mail server configured to allow outbound emails?
  #3  
Old July 9th, 2009, 03:33 PM
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,569

re: How to send mail on yahoo, hotmail


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")
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy HTML CODE IN GMAIL,Yahoo,hotmail Pratik Patel answers 3 June 26th, 2007 01:55 PM
send mail using smtp to hotmail jlconde answers 0 October 10th, 2006 11:19 AM
cant send mail to hotmail or yahoo mail erdem kemer answers 6 November 16th, 2005 12:14 PM
how to send mail in php and check whether ir rebound or not vishal answers 6 July 17th, 2005 01:12 PM