Developing Custom Workflow Activities in CRM 4.0


We can create our own custom workflow activities and register it so that they can appear inside workflow editor in CRM.

For creating custom workflow activity we need to first select Workflow Activity Library project template inside Visual Studio with framework version 3.0.

Class within the activity library should derive from Activity class or could derive from SequenceActivity class.

Let’s create a simple custom workflow class

For this add a class inside your Workflow Activity Library project.

Add reference to Microsoft.Crm.Sdk and Microsoft.Crm.SdkTypeProxy dlls.

using System.Workflow.ComponentModel;

using System.Workflow.Runtime;

using System.Workflow.Activities;

using System.Workflow.Activities.Rules;

using Microsoft.Crm.Workflow; 

namespace MyWorkflow

{

[CrmWorkflowActivity(“My First Custom Activity”,“My Custom Activity Group”)]

public class MySimpleCustomActivity :Activity

{

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

{

// custom logic

return ActivityExecutionStatus.Closed;

}

}

}

 

CrmWorkflowActivity Attribute – To allow our activity to be visible inside the workflow editor. First parameter is the name of the workflow activity and second parameter is the group name, which could be used for grouping similar kind of workflow activities.

We can create custom activity by inheriting SequenceActivity class, which would be a composite activity wherein we can add other activity available with windows workflow foundation like

IfElseActivity,IfElseBranchActivity,PolicyActivity,DelayActivity etc.

For this right click on your project and add a new Activity in your project.

Open it in design mode. We can see the option of (Drop Activities Here)

Therein we can drop the built in activities found in windows workflow foundation for building our custom logic. Here we need not override the Execute method like we did in earlier case. The sequence activity will execute the activities that we would have dragged and dropped for writing our logic.

[CrmWorkflowActivity(“My First Custom Activity”, “My Custom Activity Group”)]

 

public partial class Activity3: SequenceActivity

{

public Activity3()

{

InitializeComponent();

}

}

 

While building our workflow we could also define input and output parameter that will appear inside Set Properties dialog box while defining Step and Dyanmic Value editor inside Form Assistant respectively.

To define input and output parameters we need to make use of dependency property and CrmInput and CrmOutput Attribute.

[CrmInput(“Name”)]

[CrmDefault(“Nishant”)]

public string InputProperty

{

get { return (string)GetValue(InputPropertyProperty); }

set { SetValue(InputPropertyProperty, value); }

}

 

public static readonly DependencyProperty InputPropertyProperty =

DependencyProperty.Register(“InputProperty”, typeof(string), typeof(nameOfActivityClass));

 

Similary we can define output parameter only difference would that we will use [CrmOutput(“FullName”)] attribute.

CrmDefault attribute is optional one.

 

The same property could act as both input as well as output parameter.

 

[CrmInput(“FName”)]

[CrmOutput(“LName”)]

[CrmDefault(“Nishant”)]

public string MyProperty

{

. . . .

 

 

The following data type are supported that could be used as input/output parameter

 

String, CrmNumber, CrmDecimal, CrmFloat, CrmMoney , CrmDateTime, CrmMoney, CrmBoolean, Status, Picklist, Lookup.

 

For lookup we can specify the parameter as following

 

 

[CrmInput(“Territory”)]

[CrmReferenceTarget(“territory”)]

public Lookup TerritoryProperty

{

get { return (Lookup)GetValue(TerritoryPropertyProperty); }

set { SetValue(TerritoryPropertyProperty, value); }

}

 

public static readonly DependencyProperty TerritoryPropertyProperty =

DependencyProperty.Register(“TerritoryProperty”, typeof(Lookup), typeof(Activity1));

For picklist

[CrmInput(“AddressType”)]

[CrmAttributeTarget(“account”,“address1_addresstypecode”)]

 

public Picklist AddressTypeProperty

{

get { return (Picklist)GetValue(AddressTypePropertyProperty); }

set { SetValue(AddressTypePropertyProperty, value); }

}

 

public static readonly DependencyProperty AddressTypePropertyProperty =

DependencyProperty.Register(“AddressTypeProperty”, typeof(Picklist), typeof(Activity1));

 

Using CrmService and MetadataService within custom workflow activity through workflow context

We can register our own custom services with workflow runtime. The built in services provided by Windows workflow foundation are following

PersistenceService, QueuingService, SchedulerService, TransactionService, TrackingService etc.

Similary MS CRM has used it to register ContextService with the runtime. It provides the current context information for the workflow instance which is executing at that time.

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

{

IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));

IWorkflowContext context = contextService.Context; 

ICrmService crmService = context.CreateCrmService(); 

IMetadataService crmMetadataService = context.CreateMetadataService(); 

 

return ActivityExecutionStatus.Closed;

 

}

For registering the custom activity we need to use Plugin registration tool.

Open Plugin Registration Tool

Select Register New Assembly

Select you assmebly ( It should be signed assembly and no need to specify anything else within the plugin registration tool).

Click on Register Selected Plugin

Restart Crm Asynchronous Service

Bye..

Understanding DynamicEntity in Microsoft Dynamic CRM.


We can use the DynamicEntity to develop against entities and attributes that are not defined at design time.

Or to write code that must work on entities/attributes that would be created/added after the code is deployed.

Let’s take an example of how to use DynamicEntity for creating and updating records using Dlls(Microsoft.crm.sdk and Microsoft.crm.sdktypeproxy) and also by using web service..

Setting up CrmService

CrmAuthenticationToken myToken = new CrmAuthenticationToken();

myToken.OrganizationName = “orgname”;

myToken.AuthenticationType = 0;

CrmService myService = new CrmService();

myService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myService.Url = http://servername:port/MSCrmServices/2007/CrmService.asmx”;

myService.CrmAuthenticationTokenValue = myToken;


Creating a contact record using DynamicEntity inside Microsoft.Crm.Sdk.dll

// Creating an instance of DynamicEntity Class

// Specifying the schema name of Contact entity whose record we are

// going to create

DynamicEntity myDE = new DynamicEntity();

myDE.Name = “contact”;

// Creating an instance of StringProperty to specify firstname attribute value

StringProperty myFirstName = new StringProperty();

myFirstName.Name = “firstname”;

myFirstName.Value = “Nishant”;

// Adding it to DynamicEntity’s properties

myDE.Properties.Add(myFirstName);

// Creating an instance of StringProperty to specify lastname attribute value

StringProperty myLastName = new StringProperty();

myLastName.Name = “lastname”;

myLastName.Value = “Rana”;

myDE.Properties.Add(myLastName);

try

{

contactGuid= myService.Create(myDE);

}

catch (SoapException ex)

{

MessageBox.Show(ex.Detail.InnerXml);

}


Updating a record using DynamicEntity


DynamicEntity myDEUpdate = new DynamicEntity();

myDEUpdate.Name = “contact”;

// Create a KeyProperty to hold the guid of the record to be updated

KeyProperty myContactGuid = new KeyProperty();

myContactGuid.Name = “contactid”;

Key myContactKey=new Key();

myContactKey.Value=contactGuid;

myContactGuid.Value = myContactKey;

myDEUpdate.Properties.Add(myContactGuid);

// Create a StringProperty with the new updated value

StringProperty myFirstNameU = new StringProperty();

myFirstNameU.Name = “firstname”;

myFirstNameU.Value = “Nishu”;

myDEUpdate.Properties.Add(myFirstNameU);

try

{

myService.Update(myDEUpdate);

}

catch (SoapException ex)

{

MessageBox.Show(ex.Detail.InnerXml);

}

The above code while using DynamicEntity class inside the WebService.

Create

DynamicEntity myDE = new DynamicEntity();

myDE.Name = “contact”;

StringProperty myFirstName = new StringProperty();

myFirstName.Name = “firstname”;

myFirstName.Value = “Mickey”;

StringProperty myLastName = new StringProperty();

myLastName.Name = “lastname”;

myLastName.Value = “Mouse”;

// myDE.Properties.Add(myLastName);

myDE.Properties = new Property[] {myFirstName, myLastName };

Guid mycontactGuid = new Guid();

try

{

mycontactGuid= myService.Create(myDE);

}

catch (SoapException ex)

{

MessageBox.Show(ex.Detail.InnerXml);

}

UPDATE

DynamicEntity myDEUpdate = new DynamicEntity();

myDEUpdate.Name = “contact”;

KeyProperty myContactGuid = new KeyProperty();

myContactGuid.Name = “contactid”;

Key myContactKey = new Key();

myContactKey.Value = mycontactGuid;

myContactGuid.Value = myContactKey;

StringProperty myFirstNameU = new StringProperty();

myFirstNameU.Name = “firstname”;

myFirstNameU.Value = “Donald”;

myDEUpdate.Properties = new Property[] { myContactGuid, myFirstNameU };

try

{

myService.Update(myDEUpdate);

}

catch (SoapException ex)

{

MessageBox.Show(ex.Detail.InnerXml);

}

In the same manner we can use Retrieve,Delete method with DynamicEntity.

There are certain Request classes that have a property ReturnDynamicEntities which indicates whether to return the result as a collection of instances of the that Entity or the DynamicEntity class.

Bye..

 

Understanding and Using CrmDiscoveryService in CRM 4.0


This is a new web service introduced in CRM 4.0.

Using it we can get organization information as well as organization’s CrmService and MetadataService web service’s url end points.

The web service has three different end point based on authentication mode

Active Directory

http://servername:port/mscrmservices/2007/AD/CrmDiscoveryService.asmx

IFD –

http://servername:port/mscrmservices/2007/IFD/CrmDiscoveryService.asmx

Online –

https://dev.crm.dynamics.com/mscrmservices/2007/passport/CrmDiscoveryService.asmx

In case of IFD and Online, we neet to obtain CrmTicket information that is required.

In case of Online we also need policy information and Passport ticket.

These information provided by CrmDiscoveryService is used for configuring CrmAuthenticationToken and CrmService instances.

For on-premise

If we already know organization name and webservice Url end points that it is not necessary for us to use CrmDiscoveryService.

This is how we can use the CrmDiscoveryService for configuring our Crm Service

CrmDiscoveryService myDiscoveryService = new CrmDiscoveryService();

myDiscoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myDiscoveryService.Url = “validurl.asmx”;

// Retrieving the list of organization that user belongs

RetrieveOrganizationsRequest myRetrieveOrgRequest = new RetrieveOrganizationsRequest();

RetrieveOrganizationsResponse myRetrieveOrgResponse = (RetrieveOrganizationsResponse)myDiscoveryService.Execute(myRetrieveOrgRequest);

// Get organization information

OrganizationDetail myOrgDetail = null;

foreach (OrganizationDetail orgDetail in myRetrieveOrgResponse.OrganizationDetails)

{

if (orgDetail.Equals(“MyOrgName”))

{

myOrgDetail = orgDetail;

break;

} }

// Setting Crm Authentication Token

CrmAuthenticationToken myCrmAuthToken = new CrmAuthenticationToken();

// 0- AD , 1- IFD , 2 – Windows Live

myCrmAuthToken.AuthenticationType = 0;

myCrmAuthToken.OrganizationName = myOrgDetail.OrganizationName;

// Finally setting our CrmService

CrmService myCrmService = new CrmService();

myCrmService.CrmAuthenticationTokenValue = myCrmAuthToken;

myCrmService.Url = myOrgDetail.CrmServiceUrl;

In case of IFD, we need CrmTicket for configuring CrmAuthenticationToken and CrmService.

CrmDiscoveryService myDiscoveryService = new CrmDiscoveryService();

myDiscoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myDiscoveryService.Url = “validurl.asmx”;

// Retrieving the list of organization that user belongs

RetrieveOrganizationsRequest myRetrieveOrgRequest = new RetrieveOrganizationsRequest();

myRetrieveOrgRequest.UserId = @”domain\username”;

myRetrieveOrgRequest.Password = “password”;

RetrieveOrganizationsResponse myRetrieveOrgResponse = (RetrieveOrganizationsResponse)myDiscoveryService.Execute(myRetrieveOrgRequest);

// Get organization information

OrganizationDetail myOrgDetail = null;

foreach (OrganizationDetail orgDetail in myRetrieveOrgResponse.OrganizationDetails)

{

if (orgDetail.Equals(“MyOrgName”))

{

myOrgDetail = orgDetail;

break;

} }

RetrieveCrmTicketRequest myTickectRequest = new RetrieveCrmTicketRequest();

myTickectRequest.OrganizationName = myOrgDetail.OrganizationName;

myTickectRequest.UserId=@”domain\username”;

myTickectRequest.Password = “password”;

RetrieveCrmTicketResponse myTicketResponse = (RetrieveCrmTicketResponse)myDiscoveryService.Execute(myTickectRequest);

// Setting Crm Authentication Token

CrmAuthenticationToken myCrmAuthToken = new CrmAuthenticationToken();

myCrmAuthToken.CrmTicket = myTicketResponse.CrmTicket;

// 0- AD , 1- IFD , 2 – Windows Live

myCrmAuthToken.AuthenticationType = 1

myCrmAuthToken.OrganizationName = myOrgDetail.OrganizationName;

// Finally setting our CrmService

CrmService myCrmService = new CrmService();

myCrmService.CrmAuthenticationTokenValue = myCrmAuthToken;

myCrmService.Url = myOrgDetail.CrmServiceUrl;

In case of Windows Online deployment

We need policy information, passport ticket and CrmTicket for configuring configuring CrmAuthenticationToken and CrmService.

LogonManager – This class is used to authenticate a user with the Windows Live ID service.

To access this class we need to add a reference to following idcrlwrapper.dll

The project can be found at sdk\server\helpers\cs\idcrlwrapper

CrmDiscoveryService myDiscoveryService = new CrmDiscoveryService();

myDiscoveryService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myDiscoveryService.Url = https://dev.crm.dynamics.com/mscrmservices/2007/passport/CrmDiscoveryService.asmx“;

// Retireve Policy Information

RetrievePolicyRequest myPolicyRequest = new RetrievePolicyRequest();

RetrievePolicyResponse myPolicyResponse = (RetrievePolicyResponse)myDiscoveryService.Execute(myPolicyRequest);

LogonManager myLogonManager = new LogonManager();

string myPassportTicket = myLogonManager.Logon(“username”, “password”, “partner”, myPolicyResponse.Policy, “environment”);

myLogonManager.Dispose();

// Retrieving the list of organization that user belongs

RetrieveOrganizationsRequest myRetrieveOrgRequestLive = new RetrieveOrganizationsRequest();

myRetrieveOrgRequestLive.PassportTicket = myPassportTicket;

RetrieveOrganizationsResponse myRetrieveOrgResponseLive = (RetrieveOrganizationsResponse)myDiscoveryService.Execute(myRetrieveOrgRequestLive);

// Get organization information

OrganizationDetail myOrgDetailLive = null;

foreach (OrganizationDetail orgDetail in myRetrieveOrgResponseLive.OrganizationDetails)

{

if (orgDetail.Equals(“MyOrgName”))

{

myOrgDetailLive = orgDetail;

break;

}

}

RetrieveCrmTicketRequest myTickectRequest = new RetrieveCrmTicketRequest();

myTickectRequest.OrganizationName = myOrgDetail.OrganizationName;

myTickectRequest.PassportTicket = myPassportTicket;

RetrieveCrmTicketResponse myTicketResponse = (RetrieveCrmTicketResponse)myDiscoveryService.Execute(myTickectRequest);

// Setting Crm Authentication Token

CrmAuthenticationToken myCrmAuthToken = new CrmAuthenticationToken();

myCrmAuthToken.CrmTicket = myTicketResponse.CrmTicket;

// 0- AD , 1- IFD , 2 – Windows Live

myCrmAuthToken.AuthenticationType = 2;

myCrmAuthToken.OrganizationName = myOrgDetail.OrganizationName;

// Finally setting our CrmService

CrmService myCrmService = new CrmService();

myCrmService.CrmAuthenticationTokenValue = myCrmAuthToken;

myCrmService.Url = myOrgDetail.CrmServiceUrl;

Bye…

Using CrmDeploymentService CRM 4.0


We have a new webservice in CRM 4.0 i.e. CrmDeploymentService

This is the end-point for this web service

http://<servername%5B:port%5D>/mscrmservices/2007/crmdeploymentservice.asmx

Using CrmDeploymentService we can do the following

Create/Delete/Disable/Enable/Update/Set Default an organization etc.

There are two types of Microsoft Dynamics CRM deployment entities: Organization and Server. The Deployment SDK provides programmatic access for manipulating the Organization entity. It does not currently enable you to write code against the Server entity for actions such as enabling and disabling a Microsoft Dynamics CRM server.

We have a separate sdk for the Deployement.

We can download the sdk at the following location

http://www.microsoft.com/downloads/details.aspx?FamilyId=2874D878-E28D-4530-A185-4DEE1FCDD12E&displaylang=en

Some basic examples of using the service

// Create an instance of CrmDeploymentService

CrmDeploymentService myDeployService = new CrmDeploymentService();

myDeployService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myDeployService.Url = ” valid url”;

// To retrieve server license type information

RetrieveLicenseRequest myLicRequest = new RetrieveLicenseRequest();

RetrieveLicenseResponse myLicResponse = (RetrieveLicenseResponse)myDeployService.Execute(myLicRequest);

MessageBox.Show(“License Type “ + myLicResponse.LicenseType.ToString());

// To get the organization information

RetrieveAllRequest myRetriveAllRequest = new RetrieveAllRequest();

// only organization is supported ( other is Server)

myRetriveAllRequest.EntityName = EntityName.Organization;

RetrieveAllResponse myRetriveAllResponse = (RetrieveAllResponse)myDeployService.Execute(myRetriveAllRequest);

foreach(DeploymentEntity myEntity in myRetriveAllResponse.Entities)

{

Organization myOrganization = (Organization)myEntity;

MessageBox.Show(myOrganization.FriendlyName);

MessageBox.Show(myOrganization.Id.ToString());

MessageBox.Show(myOrganization.UniqueName);

}

//// To disable an organization

SetStateOrganizationRequest myOrgSetStateRequest = new SetStateOrganizationRequest();

myOrgSetStateRequest.EntityName = EntityName.Organization;

myOrgSetStateRequest.Id = new Guid(“4c7fc991-0a41-dd11-bfd9-001d7d22e1af”);

myOrgSetStateRequest.State = OrganizationState.Disabled;

SetStateOrganizationResponse myOrgSetStateResponse =(SetStateOrganizationResponse) myDeployService.Execute(myOrgSetStateRequest);

Bye …..

Writing a simple custom workflow activity in CRM 4.0


Let’s create our first Custom Workflow Activity for CRM 4.0.

Check this post as well

https://nishantrana.wordpress.com/2008/10/30/custom-workflow-activities-in-crm-40/

We’ll take here a very simple scenario just to understand how to write custom activity.

This Custom Activity will take as input First Name and Last Name from an entity ( say Lead) and will update it’s description attribute with (First Name + Last Name).

Create a new Workflow Activity Library within workflow project type in Visual Studio.

(Keep the version as 3.0)

Name it MyFirstCustomWFlowActivity

Add references to Microsoft.crm.sdk.dll and Microsoft.crm.sdktypeproxy.dll.

Add the following line of code in your Activity1.cs.

using Microsoft.Crm.Workflow;

using Microsoft.Crm.Sdk;

We are creating a simple activity, so here we can have our class inherit from Activity class instead of SequenceActivity.

Delete the following class Activity1.Designer.cs as our simple custom activity doesn’t require that.


Decorate the class with CrmWorkflowActivity attribute

The first parameter is the user friendly name of the custom activity that will appear in the Workflow Editor and second parameter is the name of group, it can be used for grouping similar custom workflow activity.

namespace MyFirstCustomWFlowActivity

{

[CrmWorkflowActivity(“Get First and Last Name”, “Custom Steps”)]

public class Activity1: Activity

{

}

}

Now create three dependency properties, two as input for first name and last name and one as output where we will have full name i.e. first name and last name combined.

To create dependency property

Right click inside the visual studio editor then select insert snippet and followed by Workflow then DependencyProperty – Property.

We have used CrmInput and CrmOutput Attribute to make the dependency property visible within the workflow editor and to provide a user friendly name to them.

public static DependencyProperty FirstNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register(“FirstName”, typeof(string), typeof(Activity1));

[CrmInput(“First Name”)]

public string FirstName

{

get

{

return ((string)(base.GetValue(Activity1.FirstNameProperty)));

}

set

{

base.SetValue(Activity1.FirstNameProperty, value);

}

}

public static DependencyProperty LastNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register(“LastName”, typeof(string), typeof(Activity1));

[CrmInput(“Last Name”)]

public string LastName

{

get

{

return ((string)(base.GetValue(Activity1.LastNameProperty)));

}

set

{

base.SetValue(Activity1.LastNameProperty, value);

}

}

public static DependencyProperty FullNameProperty = System.Workflow.ComponentModel.DependencyProperty.Register(“FullName”, typeof(string), typeof(Activity1));

[CrmOutput(“Full Name”)]

public string FullName

{

get

{

return ((string)(base.GetValue(Activity1.FullNameProperty)));

}

set

{

base.SetValue(Activity1.FullNameProperty, value);

} }

Now comes the main part wherein we will override the Execute method and place our custom code to combine the first name and second name.

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)

{

this.FullName = this.FirstName + this.LastName;

return ActivityExecutionStatus.Closed;

}

Now Sign the assembly

Right Click the project in Solution Explorer

Select Properties

Select Signing

Check Sign The Assembly Check box and Select an existing or new file.

Now build the assesbly.

Now we’ll register the assembly

Open the plugin registration tool

Select Register-Register New Assembly and Select the custom workflow assembly there (MyFirstCustomWFlowActivity.dll)

Click on Register Selected Plugins button to register it in the database.

Now open CRM and go to settings then workflow and create a new workflow there.

In Workflow editor you can see our custom steps group at Add Step.

Now you can proceed as you would with other workflow and add your business logic around the custom workflow activity.

Within Add Step you would be able to set value for first name and last name property within the form assistant panel.

And than we can add an Update step wherein we can get the fullname output property within local values section inside form assistant panel.

Bye..

Send Email in CRM using a Template (SendEmailFromTemplateRequest)


Hi using the following code we can send an email programmatically that uses the email-template withing CRM

Suppose you have created a web application and have a button named btnSendEmail over there.

Put the following code in it’s event handler

protected void btnSendEmail_Click(object sender, EventArgs e)

{

CrmAuthenticationToken token = new CrmAuthenticationToken();

token.AuthenticationType = 0; // AD ( On-Premise)

token.OrganizationName = “nameofyourorganization”;

CrmService myService = new CrmService();

myService.Credentials = System.Net.CredentialCache.DefaultCredentials;

myService.CrmAuthenticationTokenValue = token;

// Create an instance of email

email myEmail = new email();

//set the owner of the mail

myEmail.ownerid = new Owner();

myEmail.ownerid.type = EntityName.systemuser.ToString();

myEmail.ownerid.Value = new Guid(“26063267-7B85-DD11-B2E0-00164145E126”);

// specify the from part of the email

activityparty from = new activityparty();

from.partyid = new Lookup();

from.partyid.type = EntityName.systemuser.ToString();

// guid of the system user who is sending the mail

from.partyid.Value = new Guid(“24543267-7B85-DD11-B2E0-00164145E126”);

myEmail.from = new activityparty[] { from };

// specify the to part of the email

activityparty to = new activityparty();

to.partyid = new Lookup();

to.partyid.type = EntityName.systemuser.ToString();

to.partyid.Value = new Guid(“26063267-7B85-DD11-B2E0-00164145E126”);

myEmail.to = new activityparty[] { to };

TargetSendFromTemplateEmail myTargetSendFromTemplateEmail = new TargetSendFromTemplateEmail();

myTargetSendFromTemplateEmail.Email = myEmail;

SendEmailFromTemplateRequest mySendEmailFromTmpRequest = new SendEmailFromTemplateRequest();

// Specify entity instance id for RegardingID

mySendEmailFromTmpRequest.RegardingId = new Guid(“132C847E-028A-DD11-8E7E-00164145E126”);

// Specify the type of entity

mySendEmailFromTmpRequest.RegardingType = EntityName.opportunity.ToString();

// Specify the email instance to be sent

mySendEmailFromTmpRequest.Target = myTargetSendFromTemplateEmail;

// Specify the template to be used ( Either a global or created specfially for that entity)

mySendEmailFromTmpRequest.TemplateId = new Guid(“6963788F-048A-DD11-8E7E-00164145E126”);

SendEmailFromTemplateResponse mySendEmailFromTmpResponse =(SendEmailFromTemplateResponse)                                  myService.Execute(mySendEmailFromTmpRequest);

}

Bye….