srinivaskr Posted September 29, 2009 Posted September 29, 2009 (edited) using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls. WebParts; using System.Web.UI.HtmlControls; using System.Net.Mail; public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { //Calling the function SendMail Response.Write(SendMail("abc@gmail.com", "def@gmail.com", "ghi@yahoo.com", "Test Mail", "Test Mail Body")); } public string SendMail(string toList, string from, string ccList, string subject, string body) { MailMessage message = new MailMessage(); SmtpClient smtpClient = new SmtpClient(); string msg = string.Empty; try { MailAddress fromAddress = new MailAddress(from); message.From = fromAddress; message.To.Add(toList); if (ccList != null && ccList != string.Empty) message.CC.Add(ccList); message.Subject = subject; message.IsBodyHtml = true; message.Body = body; smtpClient.Host = "mail.server.com"; smtpClient.Port = 25; smtpClient.UseDefaultCredentials = true; smtpClient.Credentials = new System.Net.NetworkCredential("info@server.com", "password"); smtpClient.Send(message); msg = "Successful"; } catch (Exception ex) { msg = ex.Message; } return msg; } } the above is the web service code written to send a email from flex application. but this code is not working. can anyone help me debug the application. Edited September 29, 2009 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted September 29, 2009 Administrators Posted September 29, 2009 When you say it doesn't work can you give a little more detail... Does it report success but the email isn't sent? Does the exception (if raised) give any useful information? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
srinivaskr Posted September 30, 2009 Author Posted September 30, 2009 the program gave me a parse error in the directive statement <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %> the error describes that the service cannot be created. Quote
Administrators PlausiblyDamp Posted September 30, 2009 Administrators Posted September 30, 2009 If the code you posted above is for a webservice then why is it inheriting from the Page class? Have you tried creating a new webservice and just trying to incluide the code required to send the email in it? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
srinivaskr Posted October 1, 2009 Author Posted October 1, 2009 i have opened a new project as file-> new-> website-> asp.net web service and in the window written the code for the web service and while i was compiling got this error. also when i tried to change the name of the page directive it compiled successfully but am not able to publish the same to the localhost uddi registery. Quote
Administrators PlausiblyDamp Posted October 1, 2009 Administrators Posted October 1, 2009 If it is a web service it shouldn't be inheriting from the page class, try creating a new webservice and putting your code inside the webservice derived class rather than replacing the existing code with code from a page. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
srinivaskr Posted October 2, 2009 Author Posted October 2, 2009 i have successfully debugged the program but how do i now register it to the uddi registery. i want to use the same web service in another web site which is already running on the web. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.