Hi,
<code snippet>
public static void SendEmail()
{
string MSGBody = "My Message";
string MSGSubject = "My Subject";
SmtpClient smtpClient = new SmtpClient("localhost");
// OR use the following line instead
//SmtpClient smtpClient = new SmtpClient("my email client");
string AddressFrom = "me@myemailaddress.com";
string AddressTo = "them@theiremailaddress.com";
MailMessage mailMessage = new MailMessage(AddressFrom, AddressTo, MSGSubject, MSGBody);
smtpClient.Send(mailMessage);
}
</code snippet>
The above code works fine from my development environment whether I set the SmtpClient to localhost or my actual email server address. I am using IIS5.1 (default a Smtp virtual Server is also installed), winXP.
However when I try the same code on my clients server (using IIS6.0 (NO Smtp Virtual Server installed) and win2k3 I get the following errors:
1. When setting the SmtpClient to "localhost" the error is: The server response was: Requested action not take, mail box unavailable or not local
2. When setting the SmtpClient to "my email client" the error is: The server response ... Relay not permitted.
Mail Enable is on the client server, I can also telnet to the Smtp port 25 and get the following message:
"220 IS-917.[local mail address].com ESMTP MailEnable Service, Version: 1.95-- ready at [Todays date and time]
Can anyone advise what I am doing wrong or need to do so I can email from both sites
Thanks in advance
Andrew

Sending emails from my application - Not working
Wolvenshade
I understand you are wanting to use your local computer to send email however in addition, you may well need to pass networkcredentials to authenticate yourself to the email server.
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=760457&SiteID=1
This is if you are not going to be using your local computer to send emails but rather an SMTP Server service.
jackrudolf
vaughanSkyblue
Firstly localhost won't work on the server unless the server has an SMTP server running. The error you are getting when you specify the e-mail server is telling you that the server does not allow relaying of messages. Relaying involves an SMTP server receiving an e-mail that it should forward on to another domain (if I remember this correctly). Generally this is restricted as it allows people to send bulk e-mails and make it real harder to track it back to the sender. Some servers allow relaying to any *.com or *.edu but block others. Some are even more precise.
In your case it sounds like your e-mail server won't allow it. Are you using the same domain information for your receipent e-mail as the SMTP server resides. If not then it is probably rejecting it. Refer to the following article to test relaying on the server.
http://support.microsoft.com/kb/304897
Oleg Ignatov
Hi Thanks,
However can I confirm exactly what goes in the line:
NetworkCredential credential =
new NetworkCredential("user@name.com", "pwd");Which user and password should be used
For example I am trying to send via my email server so the StmpClient is declared using that IP/Path
Am I correct in then assuming that "user@name.com" is replaced with my email address (eg: "me@mydomain.com")
Is the password that used when I connect to get my emails in the normal way via for example outlook.
Sorry to ask what may seem obvious questions but so far despite a lot of searching I cannot find a simple explanation as to what the NetworkCredential call does and what each item in the call should represent.
Thanks in advance for any help.
Andrew