2012-05-02 29 views
0

我正在使用Web服務發送電子郵件。當我運行我的應用程序出現以下錯誤:實現方法錯誤消息

The method or operation is not implemented.

我在我的網站的代碼如下所示:

WebTestServiceApp.localhost.Service1 Send = new WebTestServiceApp.localhost.Service1(); 
     Send.Sendemail(txtTo.Text, txtSubject.Text, txtbody.Text); 

我在我的web服務代碼如下所示:

[WebMethod] 
    public string Sendemail(String inValueTo, String inValueSub, String inValueBody) 
    {try 
     { 
      String valueTo = inValueTo; 
      String valueSub = inValueSub; 
      String valueBody = inValueBody; 
      // String valueAttachmentPostedfile = inValueAttachmentPostedfile; //FileUpload1.PostedFile.FileName 
      // String valueAttachmentFileContent = inValueAttachemtnFileContent; //FileUpload1.FileContent.fileName 

      System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); // Creating new message. 

      message.To.Add(valueTo); 
      message.Subject = valueSub; 
      message.From = new System.Net.Mail.MailAddress("[email protected]"); 
      message.Body = valueBody; 
      message.IsBodyHtml = true; 

      // string fileName = Path.GetFileName(valueAttachmentPostedfile); // Get attachment file 
      // Attachment myAttachment = 
      //     new Attachment(valueAttachmentFileContent, fileName); 
      // if (fileName != "") 
      // { 
      //  message.Attachments.Add(myAttachment); // Send attachment 
      // } 

      System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com"); //Properties.Settings.Default.MailSMTPServer 

      smtp.Port = 587; 
      smtp.EnableSsl = true; 
      smtp.UseDefaultCredentials = false; 

      NetworkCredential netC = new NetworkCredential(Properties.Settings.Default.username, Properties.Settings.Default.password); // Useing Projects defult settings. 
      smtp.Credentials = netC; 
      smtp.Send(message); 

      return "Message has been sent"; 
     } 
     catch (Exception) 
     { 
      return "Message faild to send" ; 

     }} 

在webService的其餘代碼工作,我知道這是因爲我用它在一個工作的網站,我的問題只是傳遞的值,或者我在webS中缺少的一個步驟ervice。

任何人都可以看到一個明顯的問題,我做錯了什麼,iv在VB中使用webservices但不是C#所以有沒有區別?

+1

Sendemail方法中的...... ......究竟是什麼?只是'拋出新的NotImplementedException()'?. –

+0

在那裏,我更換了.....,你的意思是通過拋出新的NotImplementedException() – Pomster

+1

也許** Web引用**尚未更新,你是否嘗試更新相同? – V4Vendetta

回答

0

您的當前應用程序的Web引用尚未更新,因此可能會鏈接到該方法未實現的情況。

因此,檢查和工作的唯一方法是嘗試更新Web引用。