Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to send mail to an exchange email using smtp in asp.net?

Posted on 2009-07-06
6
Medium Priority
?
1,562 Views
Last Modified: 2013-11-30
Hi, i'm trying to send an email through smtp client in asp.net. It's ending with an error saying "Failure sending mail" and having inner exception as "Unable to read data from the transport connection: net_io_connectionclosed". I've tried surfing google to get this resolved and found few smtp.ServicePoint parameters to be setup but all that didn't work.

What i've come to know from my client is that the Mail Service is acquired from "networkdogsinc.com" and the mail address is an Exchange email. So far i've worked simple mail servers in asp.net and has developed working solutions but with Exchange Server it's my first experience. Also i didn't know how to access the "mail.combslawgroup.com" directly other than code or any mailing tool like outlook.

Please review the code attached for reference. Note that the From and To email address is same in this case (because this is for a Contact us page). Also the SMTPUid and SMTPPwd parameters in real code.

Please any one there to help me to get this resolved as it's a problem on one of my live sites.

Regards.
try
                {
                    MailMessage email = new MailMessage();
 
                    email.From = new MailAddress("mail@server.com");
                    email.To.Add("mail@server.com");
                    email.Subject = "Contact Us Email Subject";
                    email.Body = "email body";
 
                    SmtpClient smtp = new SmtpClient("mail.combslawgroup.com");
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    smtp.ServicePoint.MaxIdleTime = 1000;
                    smtp.ServicePoint.ConnectionLimit = 1;
                    email.IsBodyHtml = true;
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = new System.Net.NetworkCredential("SMTPUid", "SMTPPwd");
                    smtp.Send(email);
 
                    return "Your request has been submitted successfully.";
                }
                catch (Exception ex)
                {
                    return "An error occured while sending email to admin. Error :: " + ex.Message;
                }

Open in new window

0
Comment
Question by:23-degrees
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
florin_s earned 750 total points
ID: 24784225
0
 

Author Comment

by:23-degrees
ID: 24784511
Thanks for the reply but the links provided targets asp classic based code where as i need any resource for ASP.Net. Can you spell any example with asp.net code that would be sending mail to an exchange mailbox?
0
 
LVL 12

Expert Comment

by:florin_s
ID: 24784624
let me search a bit more, I'm not that good in writing code
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 24795315
Have you configured Exchange to allow the computer that this code is running on (even if it's on the Exchange server itself) to relay messages through it?
0
 

Author Comment

by:23-degrees
ID: 24796109
I'm not new to exchange server. Can you please let me know how to set up the exchange so as it may allow relaying if it is hosted by a hosting company?
0
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 24796189
Which version of Exchange?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question