hi
How to send email using exchange server. Please let know.
Kritika
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Nov 9, 2013, 12:12 AM
Here is the C# code I have used for Sending Email Messages using Exchange Server.
// Create instance of ExchangeClient class by giving credentials
ExchangeClient client = new ExchangeClient("http://MachineName/exchange/username",
"username", "password", "domain");
// Create instance of type MailMessage
MailMessage msg = new MailMessage();
msg.From = "[email protected]";
msg.To = "recipient@ domain.com ";
msg.Subject = "Sending message from exchange server";
msg.HtmlBody = "
sending message from exchange server
";// Send the message
client.Send(msg);
The follow code snippet uses EWS to send emails using Microsoft Exchange Server.
// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
// Create instance of type MailMessage
MailMessage msg = new MailMessage();
msg.From = "[email protected]";
msg.To = "recipient@ domain.com ";
msg.Subject = "Sending message from exchange server";
msg.HtmlBody = "
sending message from exchange server
";// Send the message
client.Send(msg);
I have used Aspose.Email for .NET for sending the email. I hope it will give you an idea about Sending an email Message using Exchange Server.
Iftikar HussainPosted Aug 29, 2013, 3:39 AM
Regards,
Iftikar
kritika RanaPosted Aug 29, 2013, 3:36 AM
NameSpace ns = app.GetNamespace("mapi");
Iftikar HussainPosted Aug 29, 2013, 3:29 AM
Regards,
Iftikar
kritika RanaPosted Aug 29, 2013, 3:25 AM
Iftikar HussainPosted Aug 29, 2013, 3:21 AM
kritika RanaPosted Aug 29, 2013, 3:18 AM
Iftikar HussainPosted Aug 29, 2013, 3:14 AM
kritika RanaPosted Aug 29, 2013, 3:03 AM
In the credential section we are writing email address and password but for my configuration the user name name is not the email address. Can it be possible to write some other user name for that credential.
smtp.Credentials = new NetworkCredential("rana.vikas", "paswd");
kritika RanaPosted Aug 29, 2013, 3:00 AM
can i test code on my system using exchange server of other company.
Kritika
Iftikar HussainPosted Aug 27, 2013, 7:21 AM
kritika RanaPosted Aug 27, 2013, 7:19 AM
private void SendMail(string fileContent, string sub)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "Rana Vikas");
// mailMessage.From = new MailAddress("trehan.kritika@gmail", "Vikas");
// mailMessage.From = new MailAddress("[email protected]", "Vikas Rana");
mailMessage.To.Add("[email protected]");
//mailMessage.To.Add("[email protected]");
//mailMessage.To.Add("[email protected]");
//mailMessage.To.Add("[email protected]");
mailMessage.Subject = "Spicejet-APU Performance Report " + sub;
mailMessage.IsBodyHtml = true;
mailMessage.Body = fileContent + "
";
SmtpClient smtp = new SmtpClient("xcng.flyspicejet.com");
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("[email protected]", "paswd");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mailMessage);
//mailbox.EnableSsl = true;
//using (SmtpClient mailbox = new SmtpClient("webmail.spicejet.com", 25))
//{
// mailbox.Credentials = new NetworkCredential("[email protected]", "paswd");
// mailbox.EnableSsl = true;
// mailbox.Send(mailMessage);
//}
}
Iftikar HussainPosted Aug 27, 2013, 6:51 AM
try like this
Regards,
Iftikar