Visual Studio 2012 RC で .net Framework 4.5 を使用して C# でアプリケーションを構築しています。
アプリケーションのフィードバックと質問のために、アカウントにメールを送信しています。これは小さなアプリケーションです。
数日前、私のアプリケーションは正常に動作していました。そして私はメールを受け取っていました。
現在、「メールの送信に失敗しました」という例外ポップアップが表示されます。
私は多くの微調整を試みましたが、効果はありませんでした。私のアカウントは再開を求めていません。ファイアウォールもオフにします..同じ例外がまったく機能しません。例外の詳細を添付しています。それも。ぜひご覧ください。
私を助けてください。私はグーグルをやりすぎました。
私のコードは
MailMessage message = new MailMessage();
try
{
message.To.Add(new MailAddress(mailTo));
message.From = new MailAddress(mailFrom);
//Attachment attachment = new Attachment(FileUpload1.PostedFile.FileName);
message.Subject = "McFarlane Industries Product's Registration Request";
message.Body = packageRequestContent();
message.BodyEncoding = System.Text.Encoding.UTF8;
message.SubjectEncoding = System.Text.Encoding.UTF8;
//message.Attachments.Add(attachment);
SmtpClient client = new SmtpClient();
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
System.Net.NetworkCredential nc = new System.Net.NetworkCredential(mailFrom, mailFromPass);
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = nc;
client.Send(message);
MessageBox.Show("Thank you for Registring...!", "Register Notification!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Request not submitted. " + ex.Message);
}
例外の詳細は次のとおりです。
System.Net.Mail.SmtpException was unhandled
HResult=-2146233088
Message=Failure sending mail.
Source=System
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at McFarlaneIndustriesPOSnamespace.Registration.sendMailUsingHotmail(String mailFrom, String mailFromPass, String mailTo) in e:\Works\McFarlane Industries\McFarlane Industries Point of Sale Source Code\McFarlaneIndustries\Registration.cs:line 73
at McFarlaneIndustriesPOSnamespace.Registration.buttonSendRegistrationRequest_Click(Object sender, EventArgs e) in e:\Works\McFarlane Industries\McFarlane Industries Point of Sale Source Code\McFarlaneIndustries\Registration.cs:line 47
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at McFarlaneIndustriesPOSnamespace.Program.Main() in e:\Works\McFarlane Industries\McFarlane Industries Point of Sale Source Code\McFarlaneIndustries\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
at System.Activator.CreateInstance(ActivationContext activationContext)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.IOException
HResult=-2146232800
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response)
at System.Net.Mail.StartTlsCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException: