Developing an Email Activity Control in WF

Discussion in 'ASP' started by naimish, Jul 6, 2009.

  1. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth

    Introduction



    This article describes how to develop an Email Activity Control in WF and it constructs an activity and shows how to use that activity within a workflow.

    Background



    Windows Workflow Foundation (WF) provides a visual interface for creating and hosting workflows that integrate seamlessly into line-of-business applications built on the .NET 3.0 Framework. Activity binding, one feature of Windows Workflow Foundation, allows an activity author to expose the properties of his or her activity to other activities at a workflow level. Once the properties are available at the workflow level, they can interact with the components that serve as the solution user interface. This allows developers to set activity properties dynamically in a way with which they are familiar in a Visual Studio environment.

    The code



    Code:
    Configuring Dependency Properties
    public static DependencyProperty From Property = DependencyProperty.Register("From", typeof(string),typeofSendMailActivity));
    System.Workflow.ComponentModel.Compiler.ValidationOptionAttributeSystem.
    Workflow.ComponentModel.Compiler. ValidationOption.Required)] 
    public string From
    {
    	get
    	{
    		return ((string)(this.GetValue(SendMailActivity.FromProperty)));
    	}
    	set
    	{
    		this.SetValue(SendMailActivity.FromProperty, value);
    	}
    }
    Defining an Activity Function
    protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
    {
    	MailAddress toAddress = new MailAddress(To);
    	MailAddress fromAddress = new MailAddress(From);
    	MailAddressCollection addresses = new MailAddressCollection();
    	addresses.Add(toAddress);
    	MailMessage msg = new MailMessage(fromAddress, toAddress);
    	string body = System.String.Empty;
    	msg.Body = body;//You can Customize Email Body whatever you required
    	//First Parameter SMTP Server URL and Second One Default Port
    	SmtpClient mail = new SmtpClient(MailServerUrl, 25);
    	mail.Send(msg);
    }
    
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
  3. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Did anyone understand this article ? Or should I gave more ? :(
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice