Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send email via exchange server without using smtp?

Tags:

c#

email

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.

like image 658
Scott Langham Avatar asked Aug 28 '09 15:08

Scott Langham


People also ask

Does Exchange Server use SMTP?

MS Exchange uses SMTP to send mail, but it also governs users and mailboxes for users on a domain.

What is the difference between SMTP and Exchange Server?

SMTP protocol is used to communicate to other Internet mail servers. Exchange Server is licensed both as on-premises software and software as a service (SaaS).

How do I turn off SMTP authentication?

Open the Microsoft 365 admin center and go to Users > Active users. Select the user, and in the flyout that appears, click Mail. In the Email apps section, click Manage email apps. Verify the Authenticated SMTP setting: unchecked = disabled, checked = enabled.

Is SMTP authentication required?

With the new protocols in place, an authentication mechanism (like a password) is necessary to log in to an email service provider's SMTP server. This means that only verified users can send messages via that server – providing a basic level of security against the sending of unsolicited spam and phishing emails.


3 Answers

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.

like image 72
jasonmw Avatar answered Nov 15 '22 13:11

jasonmw


You can use the new Exchange Web Services Managed API 1.0. it seems to be the best solution. heres the link.

http://msdn.microsoft.com/en-us/library/dd637749(v=exchg.80).aspx
https://blogs.technet.com/b/exchange/archive/2009/04/21/3407328.aspx
The accept will accept distribution lists as well.

The 2.0 version of the API
http://msdn.microsoft.com/en-us/library/office/dd633709.aspx

like image 33
Terry Avatar answered Nov 15 '22 13:11

Terry


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

like image 29
Austin Salonen Avatar answered Nov 15 '22 13:11

Austin Salonen