C# winform 응용 프로그램에서 전자 메일을 보내고 싶습니다. 인터넷 연결은 프록시를 사용합니다.CDO를 사용하여 프록시를 통해 전자 메일 보내기
이 내가 지금까지했던
그것은 예외가 발생 WebProxy proxy = WebProxy.GetDefaultProxy();
Console.WriteLine(proxy.Address);
if (proxy.Address!=null)
{
try
{
MailMessage oMsg = new MailMessage();
// TODO: Replace with sender e-mail address.
oMsg.From = fromGmailAddress;
// TODO: Replace with recipient e-mail address.
oMsg.To = toAddress;
oMsg.Subject = "Send Using Web Mail";
// SEND IN HTML FORMAT (comment this line to send plain text).
oMsg.BodyFormat = MailFormat.Html;
// HTML Body (remove HTML tags for plain text).
oMsg.Body = "<HTML><BODY><B>Hello World!</B></BODY></HTML>";
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com");
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/urlproxyserver", proxy.Address.Host);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/proxyserverport", proxy.Address.Port);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", true);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", gmailUsername);
oMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", gmailPassword);
SmtpMail.SmtpServer.Insert(0,"smtp.gmail.com");
SmtpMail.Send(oMsg);
oMsg = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
, 전송 서버에 연결하지 못했습니다 것입니다. Gmail smtp 서버의 포트에 대해 465,587 및 25 번 시도했습니다. 아무것도 작동하지 않습니다.
전 이메일을 통해 프록시 서버를 사용할 수없는 가능성에 대해 인터넷을 통해 읽었습니다. 내가 잘못 읽거나 이해한다면 나에게 정정 해주세요. 이 프록시는 브라우저를 사용할 때 Gmail 계정으로 로그인 할 수있게 해줍니다.
도움이 될 것입니다.
감사
작동합니다 아래 내가 웹 프록시는 일반적으로 비 HTTP 통신을 지원 생각하지 않았다 기능을 사용합니다. SOCKS 프록시를 사용하고 싶지 않으십니까? –
@ M.Babcock 튜토리얼에 대한 링크가 있습니까? 내가 어떻게 할 수 있니? – nightWatcher
[PROXY를 통한 이메일 전송을위한 .NET 라이브러리가 있습니까?] (http://stackoverflow.com/questions/3156753/is-there-net-library-for-email-sending-via-proxy) –