Hi all. I am busy writing a website and I will need to be able to send emails from it.
However, I have a problem that our network is using exchange and it seems that I can't use normal smtp. I have tried a few different ways to send emails including trying to access my gmail account and send from there. (which I have done succesfully in the past from a different company). However it seems that the smtp is blocked on this network which leaves me with the only option of going through the exchange. Is there anyone who can tell me a way to send an email through exchange or maybe even explain to me how the whole thing works or anything that may be usefull.
Thanks in advance
Ricardo
Loading
Ricardo CarvalhoPosted Jan 8, 2008, 1:41 AM
I did verify that the IP is correct. It is not the machine that the site is hosted on at the moment. For now the website is on my local machine and it will later on be moved to a different server when it goes live. I have played around with it a bit more and it turns out that there is an issue on the server with that port. I can't even telnet to the server on port 25. I have got the network administrator trying to solve the issue for me. When I use my personal laptop with 3G the emails send fine. There is nothing wrong with the code. So its just a case of unblocking the port on the server.
I will have to find out what to do there. But thanks for your help.
Ricardo
Guest UserPosted Jan 7, 2008, 1:26 PM
Default port number for non-secure connections: 25
Default port number for secure connections: 587
Also, if a secure connection is required, try setting the EnableSsl property of the Smtp object to True.
Guest UserPosted Jan 7, 2008, 1:09 PM
Ricardo CarvalhoPosted Jan 7, 2008, 2:10 AM
Thanks for your help with the above.
I tried your peice of code and it didn't go down to well.
I added the stuff to the config and used a valid log in and everything for it.
I used the code and I got the following errors:
ex = {"Failure sending mail."}
ex.InnerException = {"Unable to connect to the remote server"}
ex.InnerException.InnerException = {"No connection could be made because the target machine actively refused it"}
this is were ex is in the Catch (Exception ex)
This is basically the problem that I have been having all along while I am seraching the interent in search of help. Do you perhaps know what I can do to get around this?
Thanks Ricardo
Guest UserPosted Jan 6, 2008, 6:32 PM
I recently developed an ASP.NET 2.0 app using the client's Exchange 2003 server to send emails.
First, I needed to add the following code to the system.net section of web.config:
port="
userName="
password="
To send an email from within the app, I use the following code:
System.Net.Mail.MailAddress adrFrom = new System.Net.Mail.MailAddress(""); System.Net.Mail.MailAddress adrTo = new System.Net.Mail.MailAddress(""); Obviously you'd have to replace everything that's in angle brackets to correspond with your system, but this works for me.