Solved

smpt client for windows 7

Posted on 2011-09-26
15
436 Views
Last Modified: 2012-05-12
Hi experts,

I have used following c# code to send emails from my workplace

 SmtpClient client = new SmtpClient("clinmed.gla.ac.uk");
            MailMessage objEmail = new MailMessage();
            objEmail.From = new MailAddress(m_EmailFrom);
            objEmail.To.Add(new MailAddress(m_EmailTo));
            objEmail.Subject = m_EmailSubject;
            objEmail.Body = m_EmailMessage;
            objEmail.IsBodyHtml = true;
            client.Send(objEmail);

We have an smtp client "clinmed.gla.ac.uk" at work.

Now at home on my personal pc I need to do some testing. Can I download and install some free smtp client like i have used above to test sending email?
0
Comment
Question by:mmalik15
  • 7
  • 4
  • 2
  • +2
15 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 36598677
run your windows setup (add remove programs from the control panel), there is a SMTP installation (part of IIS if I am not mistaken)
0
 

Author Comment

by:mmalik15
ID: 36598689
Sorry I am using windows 7 professional sp1 and checked windows features already and it does not have smtp client option
0
 
LVL 33

Expert Comment

by:paulmacd
ID: 36598793
I think what you're looking for is an SMTP server (not a client, which is what you're instantiating with the .NET Framework).  Is there some reason you can't use "clinmed.gla.ac.uk" from home?
0
 

Author Comment

by:mmalik15
ID: 36598985
I have tried connecting to "clinmed.gla.ac.uk" but the exception i get is "Unable to connect to the remote server".
0
 
LVL 11

Accepted Solution

by:
Sudhakar Pulivarthi earned 400 total points
ID: 36598994
Hi,
You can use any public mail server like gmail to test ur code to send mails using that account.
SmtpClient client = new SmtpClient("smtp.gmail.com", 25); // If not try port 587
            MailMessage objEmail = new MailMessage();
            objEmail.From = new MailAddress(m_EmailFrom); // gmail mail id
            objEmail.To.Add(new MailAddress(m_EmailTo)); // any valid mail id
            objEmail.Subject = m_EmailSubject;
            objEmail.Body = m_EmailMessage;
             // Set the user credentials.
             objEmail.Credentials = new NetworkCredential("gmail user name", "gmail password");
             objEmail.EnableSsl = true
            objEmail.IsBodyHtml = true;
            client.Send(objEmail);
0
 
LVL 33

Expert Comment

by:paulmacd
ID: 36598995
Ah, well, if you have an account at one of several free e-mail providers you might be able to use one of their servers:

http://www.emailaddressmanager.com/tips/mail-settings.html

0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36599027
hi mmalik15,

Please do check and provide the port number (default is 25, which can be omitted) in the mail server "clinmed.gla.ac.uk"  using which clients from outside the network can connect to the mail server to send mails. Because inter network mails could have been able to connect with default port, but its not publicily accessible from outsiode.
There might be a provision to send mails from outside network through some other port if provided by your company admin team. If not, you can use any public mail server as specified above.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:mmalik15
ID: 36599149
thanks for the comments
I have tried this without any luck

  MailMessage objEmail = new MailMessage();
            objEmail.From = new MailAddress(m_EmailFrom);
            objEmail.To.Add(new MailAddress(m_EmailTo));
            objEmail.Subject = m_EmailSubject;
            objEmail.Body = m_EmailMessage;
            objEmail.IsBodyHtml = true;


           SmtpClient client = new SmtpClient("smtp.gmail.com", 25);
            client.Credentials = new NetworkCredential("myemailID@gmail.com", "xxxxxxxx");
            client.EnableSsl = true;


            client.Send(objEmail);

The exception i m getting now is


"An attempt was made to access a socket in a way forbidden by its access permissions 209.85.227.109:25"}"
0
 

Author Comment

by:mmalik15
ID: 36599175
I have also tried with port 587. And did try clinmed using port 25 and 587 but could not connect
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36599193
Please turn off firewall and check... antivirus might be blocking..
please turn them off and check once...
0
 

Author Comment

by:mmalik15
ID: 36599295
windows firewall and antivirus are both disabled still no luck i have also tried telnet

C:\Users\MehtabM>telnet smtp.gmail.com 587
Connecting To smtp.gmail.com...Could not open connection to the host, on port 58
7: Connect failed
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36599354
hi please check 465 port also,
Check other mail servers:
http://techblissonline.com/gmail-smtp/
0
 

Author Comment

by:mmalik15
ID: 36599403
port 465 did not give an error on telnet but when tried on the we b page I got this error in the exception after few min

"The operation has timed out."
0
 
LVL 33

Assisted Solution

by:Todd Gerbert
Todd Gerbert earned 100 total points
ID: 36599462
C:\Users\MehtabM>telnet smtp.gmail.com 587
Connecting To smtp.gmail.com...Could not open connection to the host, on port 58
7: Connect failed

That's almost certainly a firewall.
0
 

Author Closing Comment

by:mmalik15
ID: 36599500
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Email attacks are the most efficient and effective way for cyber criminals and hackers to compromise a computer or network. We often find our-self second guessing the authenticity of an email message, for such instances we can follow practical princ…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now