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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 27, 2013, 2:51 AM EDT
try like this
Regards,
Iftikar
kritika RanaRank #7,001 · 251 reputationPosted Aug 27, 2013, 3:19 AM EDT
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 HussainRank #423 · 5.9K reputationPosted Aug 27, 2013, 3:21 AM EDT
kritika RanaRank #7,001 · 251 reputationPosted Aug 28, 2013, 11:00 PM EDT
can i test code on my system using exchange server of other company.
Kritika
kritika RanaRank #7,001 · 251 reputationPosted Aug 28, 2013, 11:03 PM EDT
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");
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 28, 2013, 11:14 PM EDT
kritika RanaRank #7,001 · 251 reputationPosted Aug 28, 2013, 11:18 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 28, 2013, 11:21 PM EDT
kritika RanaRank #7,001 · 251 reputationPosted Aug 28, 2013, 11:25 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 28, 2013, 11:29 PM EDT
Regards,
Iftikar
kritika RanaRank #7,001 · 251 reputationPosted Aug 28, 2013, 11:36 PM EDT
NameSpace ns = app.GetNamespace("mapi");
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 28, 2013, 11:39 PM EDT
Regards,
Iftikar
Posted Nov 8, 2013, 7:12 PM EST
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.