0

I'm trying to send an email using C++/Cli through gMAil ... This is the code but it is not working , any suggestions?

MailMessage^ email=gcnew     
MailMessage("from@From.com","to@to.com","SUBJECT","MESSAGE");
SmtpClient^ smtp=gcnew SmtpClient("smtp.gmail.com", 587);
smtp->EnableSsl=true;   
smtp->UseDefaultCredentials = false; 
smtp->Credentials = gcnew    
System::Net::NetworkCredential("from@from.com","password");
smtp->Send(email); 
user3345850
  • 101
  • 1
  • 9
  • there is a proxy present... how to overcome this, the proxy uses port 80 – user3345850 Feb 24 '14 at 09:23
  • You can try to specify a proxy in your .config file: http://stackoverflow.com/questions/186800/is-it-possible-to-specify-proxy-credentials-in-your-web-config .... but I doubt that your proxy-server will allo CONNECT requests... Normally you have no chance to access SMTP portes directly via a proxy server... – Jochen Kalmbach Feb 24 '14 at 10:17

1 Answers1

0

First a small comment: You are not using C++, you are using C++/CLI (.NET).

For a solution, see answer of: SmtpClient wont authenticate over SSL/TLS (not pointing to gmail)

Alternatively: How can I send emails through SSL SMTP with the .NET Framework?

If you have a proxy server, you are normally without luck... of course, you can try to specify a proxy server in your config file. For more info see: Is it possible to specify proxy credentials in your web.config? But normally your proxy server will not allow CONNECT reqeusts...

Community
  • 1
  • 1
Jochen Kalmbach
  • 3,369
  • 14
  • 18