My company is using Microsoft Exchange server 2003 and outlook to send emails. I am put in charge of creating a C# windows form application program to connect to our exchange server and send an email using my credentials. I'm having a hard time connecting to the exchange server.. I don't really know how to do this. We want the email set up sort of like:
Username: "entry" Password: "entry"
I have the basic form made.. And I'm able to send an email over smtp server but I don't think I am doing it through our exchange server. Any help is appreciated. Thank you.
There are a few valid ways to send email via exchange the first is using SMTP which is what it sounds like your doing this will work fine the only issue you may have is that if you are sending to external addressees the IP Address your sending from would need to be give relay rights.
The other method of sending is to send via an Exchange mailbox for this would you need to use one of the Exchange API's for 2003 from .NET the best method is to use WebDAV see http://support.microsoft.com/kb/313128 for a sample. The difference here is that the message your sending will be saved to the sent items folder of the mailbox your sending from and because your using the same method of sending as a normal Exchange user would you don't need to worry about tripping over SPAM filters etc.
Say I wanted to go the SMTP route. I want to set it up so I can send an email from my email address in the exchange server.. so basically all I would have to do is type in my user name and password for the exchange server and then I can send an email FROM ME without even putting my email address in a "from" line. What I'm having trouble with is getting this to work. I have code, it sends an email... but I don't have the username and password part down correct. I know this because the email will still send, even if I type in a different user name or password. Is there a way to connect to the exchange server to pull this information from it? I don't know how to code that part.
i have tried but no success
server error is
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
my exchange server is 2010
can u help me
I am using SmtpClient
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
MailAddress fromAddress = new MailAddress(from);
message.From = fromAddress;
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = body;
smtpClient.Timeout = 50000;
smtpClient.Host = host; //exchange server name
smtpClient.Port = port;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("firstname.lastname@example.org", "password");
smtpClient.EnableSsl = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
What version of Exchange ? if its 2007 or 2010 make sure your sending via a Hub Server other server roles won't accept SMTP traffic
Also if your going to send authenticated emails than i would suggest you try to use client port 589
To see if your connecting enable verbose logging on the Hub Server for SMTP http://technet.microsoft.com/en-us/library/bb124531(EXCHG.80).aspx
The error you getting is basically saying you can't connect to the Port 25 on the server your trying to send through this maybe caused be a few things a lot of AV program (and ISP's) block outgoing port 25 so try testing this first from Telnet program http://support.microsoft.com/kb/153119
Also refer to http://www.systemnetmail.com/