How to send Mail using System.Net.Mail outside the company network?

Hi All,

I am trying to send mail to my ( account, but its not going and throwing error like "Mailbox unavailable. The server response was: <> No such user here".

Its working fine if i will send to our company ids. Please help me out.


SmtpClient smtp = new SmtpClient();

smtp.Host = ""; smtp.Port = 25;

//smtp.Credentials = CredentialCache;

MailMessage msg = new MailMessage();MailAddress from = new MailAddress(txtFrom.Text);

msg.Sender = from;

msg.From = from;


string[] tos = txtTo.Text.ToString().Split(';');foreach (string to in tos)


if (ValidateEmail(to))



string[] ccs = txtCc.Text.ToString().Split(';');foreach (string cc in ccs)


if (ValidateEmail(cc))



string[] bccs = txtBcc.Text.ToString().Split(';');foreach (string bcc in bccs)


if (ValidateEmail(bcc))



if (Request.QueryString.Count == 2)msg.Attachments.Add(new Attachment(fullpath + "\\" + Request.QueryString[1].ToString()));


msg.Subject = txtSubject.Text;

msg.Body = txtMessage.Text;



Jay Khanpara
10/18/2007 9:34:56 AM 93655 articles. 5 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 47

Does allow you to relay to outside servers?  Have you looked at the SMTP logs?  Does the Gmail account have you blocked as SPAM?  Have you tested to any other account?


Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
10/18/2007 1:00:23 PM

Hi Jeff,

Thanks for your suggestions.

 But I  have solved the problem other way.. Only thing I am missing is  SMTP Credentials, I have set credentials and its working fine now.

 Anyways thanks,


Jay Khanpara
10/19/2007 7:04:19 AM

Similar Artilces:

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

Sending Mail Using System.Net.Mail with out using User credentials
HI, I have an application where in i send mails based on some condition, the user is already authenticated, so i need not check the User Credentials.Right now this is how the piece lokks:- mailClient.Credentials = new NetworkCredential(USERID, USER_PWD,DOMAIN); I want to send the mail, with out validating the user credentials, Can i skip the above line. Please post aqlong with the sample code.   Thanx in Advance. Anil Kumar.   I think you cannot skip. but store user credentials in session variables after login and then pass.If this post was useful to you, please mark it as...

Problem with difference between System.Web.Mail and System.Net.Mail in using attachments
I have a web .Net app which sends emails with attachments.  After the email is sent I clean up aftermyself and delete the attachments from disk.   In upgrading to .Net 2  I changed the email logic from using system.web.mail to  (of course vs is telling me system.web.mail is obsolete).In .Net 1.1,  the files deleted with no problem but in .Net 2 when I attempt to delete  I receive The process cannot access the file ...' because it is being used by another process. If I change the code back to using system.web.mail I can delete the file...

Problem in sending mail using
I am using C# and ASP.Net2.0 for sending mail. But my problem is it is not being sent. I am not being able to understand it. I am using my gmail account for it. I am using System.Net and System .Net.Mail for sending the same. But i am getting the error ''Failure Sending Mail. Cannot connect to the server" . I have internet connection. Plz help me. It's urgent. I am attaching my code.  MailMessage mailMsg = new MailMessage();MailAddress ma = new MailAddress(; mailMsg.From = ma; mailMsg.To.Add(s);mailMsg.Subject = "Your...

System.web.mail to
I converted a web app from VS 2003 to VS 2005. i now get error message when i build it  stating system.web.mail  is obsolute,  use i redefine to but now i get other error message such as smtpMail does not exist in the current context. cannot implicitly convert type string to System.Net.Mail.MailAddress   so System.Web.Mail want work in web app convert to VS 2005 running on framework 2.0?           because if i change to System.Net.Mail  i am ...

.net 2 beta 2 - System.Net.Mail
Hi guysI'm using the System.Net.Mail namespace in .net version 2, beta 2, to send out some HTML formatted e-mails.However, for some reason when the e-mail are sent out some of the full stops from the e-mail are removed.For example, part of the e-mail contains this code<img src="" alt="">But this is what the code is like when the e-mail source code is viewed<img src="" alt="">Is this a known bug in beta 2? If so, where can I view a list of known bugs an...

need help: sending mail using
hi thr.. i am some help urgently.. i need to send mail using the cs code is          System.Net.Mail.MailMessage MyMail = new System.Net.Mail.MailMessage();        SmtpClient SmtpMail = new SmtpClient();            try            {                MyMail.From = new MailAddress("");  &n...

Help for Visual web dev isolate system.web.mail to
Hi all,  I'm new user to visual web developer express software. Laterly i found this application isolate quite some of the component namespace, like system.web.mail to net.mail. I not well understand how functional?? Does it act same as system.web.mail?? My coding below: change system.web.mail to which causing a lot error... *****Can anybody correct me or advise me how to make this code work in <%@import Namespace="" %> <script runat="server">    Public FromAddress As String = "" .......

What is the maximum size of attachement in sending mail using
I am able to send mail with attachement using System.Net.Mail. But I want to know the maximum size limit of aatchement. Thanks, Prashant It depends on your smtp server settings  MAKMark as Answer if this reply helps youMVP ASP/ASP.NetASP.Net Hosting : Host DepotMy Site : ASPSnippets Hello Mudassar Khan, Thank you very much for your reply.  Where and how to set this setting in my SMTP server???? And one more thing I want to know that there is any limit of the message body size or message size that can be sent using   Thanks, P...

difference between System.Web.Mail and System.Net.Mail
What is difference between System.Web.Mail and System.Net.Mail  namespace?What is use of both ? System.Web.Mail was in .NET Framework v1.1System.Net.Mail is in .NET Framework v2.0 and greaterSame use, although there is more functionality in System.Net.Mail since it is a later version of the framework. Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!  What All-Star said. I assume the reason it was moved to a different namespace is because the internet is actually a suite of technologies: e-mail, ftp, http (web), etc. E-mail and...

Changing System.Web.Mail to System.Net.Mail
I am trying to learn ASPI have been using the Visual Web Developer 2005I have the following line that I can not work out how to convert.<%Dim FromForm As String = ""Dim ToMe As String = ""Dim FormSubject As String = "Contact Infomation"Dim EmailText As String = "Blar Blar Blar"System.Web.Mail.SmtpMail.Send(FromForm,ToMe,FormSubject,EmailText)%>It tells me that I cannot use System.Web.Mail any more and should use System.Net.Mail. I have been unable to work out what the new code should be to get it to work.The Language is VBCan anyone tell me how to change...

Migrating from System.web.mail to
Hi Every1,I've recently used the System.web.mail to send mail, using the IIS's smtp server.Doing this, i didn't really need to do anything in the web.config file or give any special parameters to the client. It just assumed i was working with my very own smtp service that came with the IIS and everything worked fine.Now i migrated to and now i need to insert my smtp service's host location under <> in the web.config file.However, i don't know what to write there so the client will use my smtp sevice (host="localhost" doesn't work)can any1 help me on this one?t...

System.Web.Mail vs System.Net.Mail
Hi AllI was using System.Web.Mail in an application on our test server.  That worked fine.  I never had to specify a server or change any settings.  It just works.  Whatever settings the server has set up are used.  This is great.I saw that System.Web.Mail has been deprecated, so I'm trying to use System.Net.Mail.  I'm having a problem.  Net.Mail doesn't use whatever settings Web.Mail used.  I can't send e-mail with Net.Mail.  I see several people use the web.config file to set the server up, but I can't get that to work. I jus...

switching from system.web.mail to
I have been converting my code from system.web.mail to  I have been able to convert the to, from, cc, and message body to the new format easily question is how do i convert this into format?SmtpMail.SmtpServer = "server";                SmtpMail.Send(mail);Would this be the solution?SmtpClient client = new SmtpClient("server");                client.Send(mail); Here's a full example of how to per...

Web resources about - How to send Mail using System.Net.Mail outside the company network? -

Network Computing
Through a For IT, By IT editorial filter, Network Computing connects the dots between architectural approach and how technology impacts the business, ...

Talk:PlayStation Network outage - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Video games , a collaborative effort to improve the coverage of video games on Wikipedia. If ...

Legal Talk Network Podcasts For Your Holiday Season
Yes, it’s the holiday season, people. And we at Legal Talk Network understand that you can only listen to Santa Baby so many times.

Credit Suisse Eyes Social Network for Super Rich - CMO Strategy - Advertising Age
... is exploring the idea of making the money-club concept a reality, based upon a trademark filing for Eleven, an invitation-only social network ...

‘And So It Goes': Network News Vet Linda Ellerbee to Retire
Linda Ellerbee , the longtime network correspondent and anchor who wrote a bestseller about her life in TV, “And So It Goes,” will retire from ...

Dreamworks - Anime News Network Anime News Network
Columns (incl. Anime News Nina! , ANNtv , ANNCast , Answerman , Astro Toy , Brain Diving , Buried Treasure , Chicks On Anime , Crashing Japan ...

Engaging with your professional network is now easier with LinkedIn for iOS
Back in October, LinkedIn previewed a major redesign of its flagship mobile app. Now, the professional networking company has officially released ...

‘How F5 Networks Could Benefit from an Accelerated Buyback’: Deutsche
The market has been unforgiving of F5 Networks’ ( FFIV ) transition “boxes” to “Software and Recurring Services”, write Deutsche Bank’s Vijay ...

Facebook will stop tracking Belgian web users who shun the social network
Privacy issues in relation to Facebook make frequent appearances, but they tend to focus on instances of the social network using the browsing ...

Airbnbs in NYC are overwhelmingly single apartments, not giant hotel-like networks
... year, Airbnb projects that the hosts who own six or more listings will become an even smaller slice of revenue from New York. Those mega-networks ...

Resources last updated: 12/3/2015 1:12:57 AM