Hello,
I wonder how it works when you want to send an email through a proxy server.
I have code below that works if you want to send an email through for example smtp.gmail.com etc.
I have put the proxyserver address and port that the proxyserver has as the 2 arguments below.
However when I try to run the code the sending fails.
So my question is how it is possible to send an email using a proxyserver like this ?
using System.Net.Mail;
String^ Proxyserver = "210.212.85.146";
int port = 1080;
MailAddress^ to = gcnew MailAddress("To@hotmail.com");
MailAddress^ from = gcnew MailAddress("From@hotmail.com");
MailMessage^ message = gcnew MailMessage(from, to);
message->Subject = "Hello1";
message->Body = "Hello2";
SmtpClient^ smtp = gcnew SmtpClient(Proxyserver, port);
NetworkCredential^ NetworkCred = gcnew NetworkCredential();
NetworkCred->UserName = "From@hotmail.com";
NetworkCred->Password = "passWord";
smtp->Credentials = NetworkCred;
try
{
smtp->Send(message);
}
catch (Exception^ ex)
{
//Failed
}