| This article is for advanced Microsoft CRM SDK C# | | | | userAuth = bizUser.WhoAmI();// CRMEmail proxy |
| developers. It describes the technique of direct SQL | | | | objectMicrosoft.Crm.Platform.Proxy.CRMEmail email = |
| programming, when SDK doesn't have the | | | | new |
| functionality to do the job.Introduction. Looks like | | | | ls = credentials;email.Url = crmDir + "CRMEmail.srf";// |
| Microsoft CRM becomes more and more popular, | | | | Set up the XML string for the activitystring |
| partly because of Microsoft muscles behind it. Now it | | | | strActivityXml = "";strActivityXml += "";strActivityXml |
| is targeted to the whole spectrum of horizontal and | | | | += "") + "]]>";strActivityXml += "";strActivityXml += |
| vertical market clientele. It is tightly integrated with | | | | userId.ToString("B") + "";strActivityXml += "";// Set |
| other Microsoft Business Solutions products such as | | | | up the XML string for the activity partiesstring |
| Microsoft Great Plains, Solomon, Navision (the last | | | | strPartiesXml = "";strPartiesXml += "";strPartiesXml |
| two in progress).Here we describe the technique of | | | | += "" + crmUser.GetEmailAddress() + "";strPartiesXml |
| creating closed activity-email using MS CRM SDK and | | | | += "" + |
| direct SQL programming.Imaging something like this. | | | | r.ToString() + "";strPartiesXml += ""+ |
| You need to handle incoming email before it is | | | | crmUser.GetId().ToString("B") + "";strPartiesXml += |
| committed to MS Exchange database. You need to | | | | "";strPartiesXml += |
| analyze if incoming email doesn't have GUID in its | | | | rtiesXml += "";strPartiesXml += "";strPartiesXml += |
| Subject (GUID will allow MS CRM Exchange | | | | "";strPartiesXml += "" + mailFrom + "";if (objectType |
| Connector to move email to Microsoft CRM and | | | | == |
| attach it to the Contact, Account or Lead) - then | | | | Microsoft.Crm.Platform.Types.ObjectType.otAccount) |
| you still need to lookup MS CRM in case if one of the | | | | {strPartiesXml += "" + |
| accounts, contacts or leads has email address that | | | | String() + "";}else if (objectType == |
| matches with sender email address - then you need | | | | Microsoft.Crm.Platform.Types.ObjectType.otContact) |
| to create closed activity-email in MS CRM, attached | | | | {strPartiesXml += "" + |
| to the object and placed into general queue.How to | | | | String() + "";}else if (objectType == |
| create MS Exchange handler is outside of the scope, | | | | Microsoft.Crm.Platform.Types.ObjectType.otLead) |
| please see this article: the code below is classical MS | | | | {strPartiesXml += "" + |
| CRM SDK and it will create activity email:public Guid | | | | ing() + "";}strPartiesXml += ""+ objectId.ToString("B") |
| CreateEmailActivity(Guid userId, int objectType, Guid | | | | + "";strPartiesXml += "";strPartiesXml += |
| objectId, string mailFrom, CRMUser crmUser, string | | | | l += "";strPartiesXml += "";strPartiesXml += |
| subject, string body) {try {log.Debug("Prepare for Mail | | | | "";log.Debug(strPartiesXml);// Create the e-mail |
| Activity Creating");// BizUser proxy | | | | objectGuid emailId = new Guid(email.Create(userAuth, |
| objectMicrosoft.Crm.Platform.Proxy.BizUser bizUser = | | | | strActivityXml, strPartiesXml));return emailId;}catch |
| new | | | | (System.Web.Services.Protocols.SoapException e) |
| Microsoft.Crm.Platform.Proxy.BizUser();ICredentials | | | | {log.Debug("ErrorMessage: " + e.Message + " " + |
| credentials = new NetworkCredential(sysUserId, | | | | e.Detail.OuterXml + " Source: " + e.Source);}catch |
| sysPassword, sysDomain);bizUser.Url = crmDir + | | | | (Exception e) {log.Debug(e.Message + " |
| "BizUser.srf";bizUser.Credentials = | | | | " + e. |
| credentials;Microsoft.Crm.Platform.Proxy.CUserAuth | | | | |