tags:

views:

1272

answers:

2

Hi,

I'm trying to send an email from c# code via our company's exchange server.

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("exchangebox1.mycompany.com");
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage("[email protected]",
                "[email protected]",
                "title here",
                "body here");
            client.Send(msg);

When I run this I get SmptException saying "Service not available, closing transmission channel. The server response was 4.3.2 Service not available, closing transmission channel".

I'm interpreting this to mean SMTP is not enabled on our exchange box and that I need to use native Exchange Server commands to send the mail. Is this right, or should SMTP always work?

Additionally, is it possible the exchange server could have been configured to only allow certain computers/users to send main via SMTP?

How can I send mail via the Exchange Server without using SMTP?

Thanks.

+1  A: 

You can use the WCF Exchange Server Mail Transport an example of how to implement is Here

Specifically regarding sending messages it says

When an application sends a message, it calls the Send method on the current output channel, which must be open. The output channel serializes the message to a string and creates the message in the Drafts folder. It sets the appropriate values in the e-mail fields. When the message has been created, it is moved into the Outbox. This occurs through CEMAPI on the device or through Exchange Web Services on the desktop. On the device, messages in the Outbox are synchronized with other outgoing messages, as defined by ActiveSync.

Jason w
+1  A: 

Try adding these two lines prior to sending:

client.UseDefaultCredentials = true;
client.EnableSsl = true;

It's most likely an issue with there being no credentials so I'll cheat a little from Google...
From dailycode.net

Austin Salonen
Thanks for the help. I'm afraid I get the same exception.
Scott Langham