Wednesday, May 2, 2012

Implementing method error message

I'm working on a web service to send an email. When i run my application I get the following error:

The method or operation is not implemented.

My Code in my website looks like:

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

My code in my webService looks like:

public string Sendemail( String inValueTo, String inValueSub, String inValueBody)
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.Subject = valueSub;
message.From = new System.Net.Mail.MailAddress("");
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(""); //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;

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


The rest of the code in the webService works, i know this because i used it in a working website, my problem is just passing the values though or a step i'm missing in the webService.

Can anyone see a obvious problem and what am i doing wrong, iv used webservices in VB but not C# so is there a difference?

No comments:

Post a Comment