Click here to Skip to main content
15,919,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I have been trying to send en email from an ASP.NET application on a Windows 7 platform. I installed IIS7 and configured the SMTP section but to no avail. I tried hard looking my problem in the internet but i cant find the solution.its saying 'No connection could be made because the target machine actively refused it 127.0.0.1:25'

SmtpClient client = new SmtpClient("127.0.0.1", 25);
MailMessage message = new MailMessage("no-reply@test.com", "markspiteri1@gmail.com", "Subject subbbbb", "bodyy");
client.Send(message);


I would rly appreciate ur help.thx
Posted
Updated 6-Aug-11 0:45am
v2

try this...

string subject = "mention subject here";
        try
        {
            
            string emailTo = "uremail";
            string emailfrom="uremail";
            string body = "urbody";
            MailMessage objmail = new MailMessage(emailfrom, emailTo, subject,body);
 

            SmtpClient smtpclnt = new SmtpClient("smtp.gmail.com", 587);
            smtpclnt.DeliveryMethod = SmtpDeliveryMethod.Network;
 
            smtpclnt.UseDefaultCredentials = true;
            smtpclnt.EnableSsl = true;
            smtpclnt.Credentials = new System.Net.NetworkCredential("username", "password");
            smtpclnt.Send(objmail);
        }
        catch (Exception ex)
        {
           
        }
 
Share this answer
 
Comments
Mark Spiteri 6-Aug-11 9:05am    
i have already done that once using the gmail smtp server. i now wanted to do the same thing with an smtp server i set myself with the IIS. i dunno if its possible but i here ppl doing it. thanks for ur reply tho :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900