Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by PlausiblyDamp
Posted

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.

Posted
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.
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...