Software Information |
|
Microsoft CRM Customization ? Programming Closed Email Activity
Microsoft CRM is CRM answer from Microsoft and attempt to get market share from Siebel, Oracle and others traditional Client Relationship Management System vendors. Microsoft CRM uses all the spectrum of Microsoft recent technologies: .Net, MS Exchange, MS Outlook, MS SQL Server, Replication, Indexing, Active Directory, Windows 2000/2003 security model, C#, VB.Net, HTML, XML Web Service, XLTP, Javascript to name a few. Today's topic is Activity of email type programming - you usually deal with these customizations when you improve Microsoft Exchange CRM connector. How do you create closed activity - this is the main discussion topic. We'll use C#.Net coding One of the roles of our Exchange Event Handler/Sink is creation MS CRM Closed Activity in handling 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 direct access to MS CRM Database. Let's first look at the Closed Activity creation algorithm: 1. First we need to understand the entity we need to create activity for: Account, Lead or Contact. The selection should use specific 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 closed Activity 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 method to create closed activity: public Guid CreateEmailActivity(Guid userId, int fromObjectType, Guid fromObjectId, int toObjectType, Guid toObjectId, string mailFrom, string mailTo, string subject, string body) { try { log.Debug("Prepare for Mail Activity Creating"); // BizUser proxy object Microsoft.Crm.Platform.Proxy.BizUser bizUser = new Microsoft.Crm.Platform.Proxy.BizUser(); ICredentials credentials = 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 string for the activity string strActivityXml = ""; strActivityXml += ""; strActivityXml += "") + "]]>"; strActivityXml += ""; strActivityXml += userId.ToString("B") + ""; strActivityXml += ""; // Set up the XML string for the activity 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); // Create 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 activity just created be shown correctly you need to setup it's flags according to MS CRM standards: public void UpdateActivityCodes(Guid emailId) { try { OleDbCommand command = 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 update activity 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 command = 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 update activity 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! [email protected] About The Author Boris Makushkin is Lead Software Developer in Alba Spectrum Technologies ? USA nationwide 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 internationally (www.albaspectrum.com), he is Microsoft CRM SDK, C#, VB.Net, SQL, Oracle, Unix developer. Boris can be reached: 1-866-528-0577 or [email protected].
|
RELATED ARTICLES
Beware of The Pirated Software E-Mail Scams! You have gotten those E_Mails buy software at deep discounts. It is very tempting to save 85% to 95% on your favorite Software Titles. Why would you pay $279 for Windows XP when you can pay $49. Most of the times these are Pirated copies of the Software. You can run into huge problems later when you seek upgrades, Support or Security patches. Microsoft Great Plains Implementation for Midsize & Large Corporation: Lockbox Processing Microsoft Great Plains is now targeting large and midsize businesses and being matured ERP has advanced, but still very simple in use modules and features: Lockbox Processing for Accounts Receivables, Customer/Vendor Consolidation, Multicurrency etc. We'll try to cover these features in the series of small articles to help decision maker and end user understand the feature and how does it work to make a decision to purchase additional nice modules. In our opinion large corporation, which had to use ERP with rich functionality in the past, doesn't have to do it in our new time. There are few reasons to switch to cheaper ERP, the most important are: database platform reliability improvement ? nowadays MS SQL Server does excellent job and has most of the former instability and maintenance issues resolved. The second reason ? MS Windows server is now close to be considered as a solid rock and you do not have to reboot it on the regular basis to fix all the types of "memory leaks", etc. OK, lets review Lockbox processing: Chinese Input - Step by Step Instruction on How to Input Chinese Characters in English Windows XP Enabling Chinese input is quick and easy, there are only a few steps you need go through to install the Chinese Language support and input method before you can type Chinese in your word processor or other program. Microsoft CRM Development Microsoft CRM is CRM answer from Microsoft Business Solutions. The Secret of the Layer Styles Dialogue When you double-click a layer in the Layer Palette, you will access the Layer Style dialogue box. Here, you can set many eye-catching layer styles such as Bevel & Emboss, Drop Shadow, Inner Shadow, etc. Microsoft CRM Data Import FAQ Microsoft CRM has built-in conversion tool, however you should probably first try third party conversion tool, such as Scribe. It is relatively expensive and has bunch of importing capabilities, that you might never use and need. Scribe allows you to map objects in source and target, when source is ACT! for example. If you are just realized the need to load data into CRM ? please research Microsoft CRM import tool and Scribe. Here we will describe other option and possibilities Microsoft CRM Customization - Processing In/Out-Going Email Messages We would like to give you several situations, when you may need custom development and programming to improve Microsoft CRM functionality. This overview is for programmer, software developer, IT specialist, database administrator. Demand More From Your Lead Tracking Software An integral part of any quality CRM system is lead tracking software. This is the part of the system that helps you gather customer data from your sales force. The ideal lead tracking software package, however, won't just tell you where the sales are coming from, but will help generate revenue by pointing sales representative to higher conversion segments of your customer base. Groupware and Version History: Collaboration Series #1 This article is the first of a series of articles exploring specific aspects of groupware. The brief informational articles in this series discuss some of the technologies associated with groupware, as well as some of the characteristics of groupware. Some of these characteristics may go hand in hand with business collaborative needs. Other characteristics go beyond what some groupware providers have to offer. The purpose of these articles is to equip the groupware user or investigator with helpful knowledge about the product in order to enable more effective use or to lead the investigator to the groupware service he or she is looking for. This first article explores Version History, a service that can be provided in groupware in order to simplify version tracking. Crystal Reports for Microsoft Great Plains Microsoft Business Solutions ? Great Plains is designed to meet and extend the needs of small and mid-size organizations for its business success. Its comprehensive accounting and business management applications also provide businesses with capabilities to customize various modules of the Great Plains software to fit to their specific needs. Because of these potentials, Great Plains has been targeted to the whole spectrum of both horizontal and vertical clientele. Microsoft Great Plains Implementation: Collection Management ? Overview For Consultant Microsoft Business Solutions Great Plains is very good fit for mid-size company and probably good budget solutions for large corporation. Being matured product ? Great Plains provides such horizontal solutions as Collection department automation. The most common question we hear in collection department is how we assign problem clients to specific collection manager and how she/he works with them one by one, simply by hitting next arrow button. This is not possible in Great Plains Accounts Payable module and this is where Collection Management module comes to the scenes. Microsoft Great Plains RW: Report Writer Microsoft Business Solutions Great Plains is marketed for mid-size companies as well as Navision (which has very good positions in Europe and emerging markets where it can be easily localized). Manufacturing Solutions for Microsoft Great Plains ? Overview for Consultant Microsoft Business Solutions Great Plains has full-featured manufacturing set of modules. In this small article we would like to give you highlights on what kinds of light customization you could deploy, before jumping into Microsoft Great Plains Manufacturing realm. Great Plains Manufacturing is targeted to discrete manufacturing clientele, which is opposite to process manufacturing ? food processing, mining, including precious metals/gold/platina, oil and gas / chemicals / agriculture. Manufacturing from accounting stand point is moving inventory into work in progress and then into finished goods. And this is where we have fundamental difference between discrete and process manufacturing. Linux for Home Users Hey Guys! Don't raise your eyebrows or fear by hearing the word Linux. It is as user friendly as windows. Just take a look at the articles below and all myths about Linux in your mind will disappear. It?s Back!! WordPerfect?s Amazing Comeback Have you noticed WordPerfect is gearing up for a comeback in a big way? And fortunately, they are succeeding. If you're like me, an ole' diehard WordPerfect 5 user, this is music to my ears. I love Microsoft Word, but I long for some of the features WordPerfect had to offer. Microsoft Axapta, Navision or Great Plains: ERP Selection for Large Corporation If you would like to pick something from Microsoft, or its ERP subdivision ? Microsoft Business Solutions, and in case of large public company, you should consider these three: Axapta, Navision or Great Plains. We are not talking about Solomon here, because it is recommended for project organization. You should probably be aware about specific product life cycle (or is it new or mature one on the market), database platform, average implementation cycle, typical customization requirements, rich vs. standard ERP functionality, etc. Also you should get comparison from relatively objective source, if you are asking to compare somebody, who implements and sells Great Plains ? more likely these people will try to prove that you need Great Plains and it is the best fit. On the other hand if you ask large consulting practice with regional offices to make comparison for you ? you should know that specific regional office might operate with maximum independence and promote, say Navision only. Defining OLAP Solutions and Data Warehouse design This tutorial covers OLAP solutions used by Data warehouses and understanding Data Warehouse design. The enterprise needs to ask itself certain fundamental questions before actually launching on the process of designing the data warehouse. It must begin with a conviction that a data warehouse would really help its business and the return on investment will make it worth it. Integrating Microsoft Great Plains Accounting/ERP: RMS, CRM, eCommerce, Lotus Domino ? overview Microsoft Business Solutions Great Plains has substantial market share among horizontal and vertical clientele in the USA, Canada (including French version for Quebec/Montreal), UK, Australia, New Zealand, Spanish speaking Latin and Central America, South Africa and Middle East. Nowadays ERP can not stay as it is off-the-shelf product ? it requires integration with Legacy or newly implemented systems, such as CRM, Retail Management applications, custom in-house made business systems (transportation/cargo tracking, etc). The tendency is that if company uses Microsoft-driven computer park (Windows domain, SQL Servers, MS Exchange) the rest of the ERP/CRM applications are Windows-oriented. However you can have successful bridge between non-Microsoft ERP and Great Plains: Oracle, IBM Lotus Notes/Domino, DB2 or others), usually it involves Java/CORBA/EJB/JSP type of expertise. The Truth about Colossus: Are You Just A Magnetic Image? What is Colossus? Best Spyware Removers Finding the best spyware removers to detect and remove spyware and adware from your computer is much easier if you consider a few things before you make your purchase. Here are a few things to keep in mind when looking for a spyware protection program. |
home | site map |
© 2005 |