Software informational articles

Microsoft crm customization ? encoding blocked email bustle - software

 

Microsoft CRM is CRM key from Microsoft and challenge to get promote share from Siebel, Augur and others conventional Client Association Management Coordination vendors. Microsoft CRM uses all the spectrum of Microsoft contemporary technologies: . Net, MS Exchange, MS Outlook, MS SQL Server, Replication, Indexing, Energetic Directory, Windows 2000/2003 defense model, C#, VB. Net, HTML, XML Web Service, XLTP, Javascript to name a few.

Today's topic is Action of email type indoctrination - you commonly deal with these customizations when you better Microsoft Chat CRM connector. How do you build blocked commotion - this is the main debate topic. We'll use C#. Net coding

One of the roles of our Altercation Event Handler/Sink is conception MS CRM Blocked Commotion in behavior incoming and outgoing email messages. The interaction with Microsoft CRM uses two approached - using MS CRM SDK (handling inbound and outbound XML messages) and via aim admittance to MS CRM Database. Let's first look at the Blocked Bustle conception algorithm:

1. First we need to be au fait with the being we need to build doings for: Account, Lead or Contact. The assortment be supposed to use definite criteria - in our case this is email address:

if ((crmAccount = crmConnector. GetAccount(mailboxFrom)) != null) {

}

else if ((crmContact = crmConnector. GetContact(mailboxFrom)) != null) {

}

else if ((crmLead = crmConnector. GetLead(mailboxFrom)) != null) {

}

2. Then we have to get GUID of MS CRM user, who owns this entity, C# code like this:

crmUser = crmConnector. GetUser(crmAccount. GetOwnerId());

3. Next step is blocked Doings creation:

emailId = crmConnector. CreateEmailActivity(

crmUser. GetId(),

Microsoft. Crm. Platform. Types. ObjectType. otAccount, crmAccount. GetId(),

Microsoft. Crm. Platform. Types. ObjectType. otSystemUser, crmUser. GetId(),

crmAccount. GetEmailAddress(), crmUser. GetEmailAddress(), sSubject, sBody);

4. The approach to construct blocked activity:

public Guid CreateEmailActivity(Guid userId, int fromObjectType, Guid fromObjectId, int toObjectType, Guid toObjectId, filament mailFrom, chain mailTo, cord subject, filament body) {

try {

log. Debug("Prepare for Mail Doings Creating");

// BizUser proxy object

Microsoft. Crm. Platform. Proxy. BizUser bizUser = new Microsoft. Crm. Platform. Proxy. BizUser();

ICredentials id = new NetworkCredential(sysUserId, sysPassword, sysDomain);

bizUser. Url = crmDir + "BizUser. srf";

bizUser. Credentials = credentials;

Microsoft. Crm. Platform. Proxy. CUserAuth userAuth = bizUser. WhoAmI();

// CRMEmail proxy object

Microsoft. Crm. Platform. Proxy. CRMEmail email = new Microsoft. Crm. Platform. Proxy. CRMEmail();

email. Credentials = credentials;

email. Url = crmDir + "CRMEmail. srf";

// Set up the XML chain for the activity

string strActivityXml = "";

strActivityXml += "";

strActivityXml += "") + "]]>";

strActivityXml += "";

strActivityXml += userId. ToString("B") + "";

strActivityXml += "";

// Set up the XML line for the bustle parties

string strPartiesXml = "";

strPartiesXml += "";

strPartiesXml += "" + mailTo + "";

if (toObjectType == Microsoft. Crm. Platform. Types. ObjectType. otSystemUser) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otSystemUser. ToString() + "";

}

else if (toObjectType == Microsoft. Crm. Platform. Types. ObjectType. otAccount) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otAccount. ToString() + "";

}

else if (toObjectType == Microsoft. Crm. Platform. Types. ObjectType. otContact) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otContact. ToString() + "";

}

else if (toObjectType == Microsoft. Crm. Platform. Types. ObjectType. otLead) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otLead. ToString() + "";

}

strPartiesXml += ""+ toObjectId. ToString("B") + "";

strPartiesXml += "";

strPartiesXml += Microsoft. Crm. Platform. Types. ACTIVITY_PARTY_TYPE. ACTIVITY_PARTY_TO_RECIPIENT. ToString();

strPartiesXml += "";

strPartiesXml += "";

strPartiesXml += "";

strPartiesXml += "" + mailFrom + "";

if (fromObjectType == Microsoft. Crm. Platform. Types. ObjectType. otSystemUser) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otSystemUser. ToString() + "";

}

else if (fromObjectType == Microsoft. Crm. Platform. Types. ObjectType. otAccount) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otAccount. ToString() + "";

}

else if (fromObjectType == Microsoft. Crm. Platform. Types. ObjectType. otContact) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otContact. ToString() + "";

}

else if (fromObjectType == Microsoft. Crm. Platform. Types. ObjectType. otLead) {

strPartiesXml += "" + Microsoft. Crm. Platform. Types. ObjectType. otLead. ToString() + "";

}

strPartiesXml += ""+ fromObjectId. ToString("B") + "";

strPartiesXml += "";

strPartiesXml += Microsoft. Crm. Platform. Types. ACTIVITY_PARTY_TYPE. ACTIVITY_PARTY_SENDER. ToString();

strPartiesXml += "";

strPartiesXml += "";

strPartiesXml += "";

log. Debug(strPartiesXml);

// Construct the e-mail object

Guid emailId = new Guid(email. Create(userAuth, strActivityXml, strPartiesXml));

return emailId;

}

catch (System. Web. Services. Protocols. SoapException e) {

log. Debug("ErrorMessage: " + e. Message + " " + e. Detail. OuterXml + " Source: " + e. Source);

}

catch (Exception e) {

log. Debug(e. Message + " " + e. StackTrace);

}

return new Guid();

}

5. To make the bustle just bent be shown appropriately you need to setup it's flags according to MS CRM standards:

public void UpdateActivityCodes(Guid emailId) {

try {

OleDbCommand authority = conn. CreateCommand();

command. CommandText = "UPDATE ActivityBase SET DirectionCode = (?), StateCode = (?), PriorityCode = (?) WHERE ActivityId = (?)";

command. Prepare();

command. Parameters. Add(new OleDbParameter("DirectionCode", Microsoft. Crm. Platform. Types. EVENT_DIRECTION. ED_INCOMING));

command. Parameters. Add(new OleDbParameter("StateCode", Microsoft. Crm. Platform. Types. ACTIVITY_STATE. ACTS_CLOSED));

command. Parameters. Add(new OleDbParameter("PriorityCode", Microsoft. Crm. Platform. Types. PRIORITY_CODE. PC_MEDIUM));

command. Parameters. Add(new OleDbParameter("ActivityId", emailId));

log. Debug("Prepare to bring up to date action code " + emailId. ToString("B") + " in ActivityBase");

command. ExecuteNonQuery();

}

catch(Exception e) {

log. Debug(e. Message + " " + e. StackTrace);

}

}

public void UpdateActivityQueueCodes(Guid emailId, Guid queueId) {

try {

OleDbCommand be in charge = conn. CreateCommand();

command. CommandText = "UPDATE QueueItemBase SET Priority = (?), State = (?), QueueId = (?) WHERE ObjectId = (?)";

command. Prepare();

command. Parameters. Add(new OleDbParameter("Priority", Microsoft. Crm. Platform. Types. PRIORITY_CODE. PC_MEDIUM));

command. Parameters. Add(new OleDbParameter("State", Microsoft. Crm. Platform. Types. ACTIVITY_STATE. ACTS_CLOSED));

command. Parameters. Add(new OleDbParameter("QueueId", queueId));

command. Parameters. Add(new OleDbParameter("ObjectId", emailId));

log. Debug("Prepare to fill in action queue code " + emailId. ToString("B") + " in QueueItemBase");

command. ExecuteNonQuery();

}

catch(Exception e) {

log. Debug(e. Message + " " + e. StackTrace);

}

}

Happy customizing, implementing and modifying! If you want us to do the job - give us a call 1-866-528-0577! help@albaspectrum. com

About The Author

Boris Makushkin is Lead Software Developer in Alba Spectrum Technologies - USA all over the country Microsoft CRM, Microsoft Great Plains customization company, based in Chicago, Boston, San Francisco, San Diego, Los Angeles, Houston, Dallas, Atlanta, Miami, Montreal, Toronto, Vancouver, Madrid, Moscow, Europe and worldwide (www. albaspectrum. com), he is Microsoft CRM SDK, C#, VB. Net, SQL, Oracle, Unix developer. Boris can be reached: 1-866-528-0577 or borism@albaspectrum. com.

borism@albaspectrum. com


MORE RESOURCES:
Developed by:
home | site map
goldenarticles.net © 2018