Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to send an email using the following code:
C#
try
{
    SmtpClient c = new SmtpClient();
    MailMessage msg = new  Message("muhammad.imraan@gmail.com", "i_muhmmad@yahoo.co.in", "bla bla", 
    "We are Successfull using our programatic Email");
    c.Host = Dns.GetHostName();
    c.Credentials = CredentialCache.DefaultNetworkCredentials;
    c.Send(msg);
}
catch (Exception ex)
{
}


I have enabled SMTP on my system.
There is no error message while running this code. The problem is, I don't receive the email. The message is stored in the queue folder, but not delivered.
Can you please guide me through the process.

Thank You
Regards
Posted
Updated 11-Feb-10 6:00am
v4

I think this will help you to send mails from your gmail account.
How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^]

Actually you didnt mentioned the smtp port and the smtp server address while declaring the SmtpClient.

I hope the article helps u.

Cheers
:rose:
 
Share this answer
 
It sounds like your SMTP server is configured incorrectly.

Have you tried sending mail using an email client?

Have you tried sending mail to different domains?

What version of Windows and IIS ( if that's what you are using )?

Nick
 
Share this answer
 
Well, I'm not sure if this works when you wanna send email from a yahoo account to a gmail one (or vice versa). you know, actually you need a valid smtp host (a smtp host on localhost will be good for sending and recieving emails on current computer, I dont think it will be usefull when you want send emails to another accounts.) like gmail.
do this :

<br />
SmtpClient c = new SmtpClient("smtp.gmail.com", 465);<br />


or

<br />
SmtpClient c = new SmtpClient("smtp.gmail.com", 587);<br />


and of course you'll need to authenticate. see this :
http://mail.google.com/support/bin/answer.py?answer=13287&query=pop&topic=0&type=f&ctx=en:search[^]

----------------------------
Regards

H.Maadani
 
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