Search

SendEmail Message

Sends an e-mail message.



//# The following code shows how to use the SendEmail message.

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create a SendEmail request.
SendEmailRequest req = new SendEmailRequest();
req.EmailId = new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC");
req.TrackingToken = "";
req.IssueSend = true;

// Send the e-mail message.
SendEmailResponse res = (SendEmailResponse)service.Execute(req);




Get Record Guid by name

//Change the fetch query as per use
 
/* Jscript */


document.getBuGuid = function(product_nm){
//var _d_fxml = "";
var _d_fxml = "<fetch mapping='logical'><entity name='new_businessinterest'><no-attrs/><filter type='and'><condition attribute='new_name' operator='eq' value='"+product_nm+"'/></filter></entity></fetch>";
//var _e_fxml = CrmEncodeDecode.CrmHtmlEncode(_d_fxml);
var soap_header= document.genSoap(_d_fxml);
var ajResponse = document.ajaxSoap(soap_header);

var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM"); //Create an XML document that you can parse.o
oXmlDoc.async = false;

oXmlDoc.loadXML(ajResponse); //Load the XML document that has the UnEncoded results.
var results = oXmlDoc.getElementsByTagName('resultset');
var bu_guid = oXmlDoc.selectNodes("//new_businessinterestid")[0].text;
var re1='.*?'; // Non-greedy match on filler
var re2='([A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12})'; // SQL GUID 1
var p = new RegExp(re1+re2,["i"]);
var m = p.exec(bu_guid);
if (m != null)
{
var guid1=m[1];
return(guid1.replace(/ }
};

uuEncode and uuDecode

Uuencoding is a form of binary-to-text encoding that originated in the Unix program uuencode, for encoding binary data for transmission over the uucp mail system. The name "uuencoding" is derived from "Unix-to-Unix encoding". Since uucp converted characters between various computers' character sets, uuencode was used to convert the data to fairly common characters that were unlikely to be "translated" and thereby destroy the file. The program uudecode reverses the effect of uuencode, recreating the original binary file exactly. uuencode/decode became popular for sending binary files by e-mail and posting to usenet newsgroups, etc. It has now been largely replaced by MIME and yEnc. With MIME, files that might have been uuencoded are transferred with base64 encoding.

  
//uuEncode and uuDecode
using System;

namespace CSUUCodec
{
public class CSUUCodec
{
public CSUUCodec()
{

}

public string uuDecode(string sBuffer)
{
string str1=String.Empty;

int j = sBuffer.Length ;
for (int i = 1; i <= j; i += 4)
{
str1 = String.Concat(str1, Convert.ToString((char)(((int)Convert.ToChar( sBuffer.Substring ( i-1, 1)) - 32) * 4 + ((int)Convert.ToChar( sBuffer.Substring( i , 1)) - 32) / 16)));
str1 = String.Concat(str1, Convert.ToString((char)(((int)Convert.ToChar( sBuffer.Substring( i , 1)) % 16 * 16) + ((int)Convert.ToChar(sBuffer.Substring( i + 1, 1)) - 32) / 4)));
str1 = String.Concat(str1, Convert.ToString((char)(((int)Convert.ToChar(sBuffer.Substring ( i + 1, 1)) % 4 * 64) + (int)Convert.ToChar( sBuffer.Substring( i + 2, 1)) - 32)));
}
return str1;
}

public string uuEncode(string sBuffer)
{
string str1=String.Empty;

if (sBuffer.Length % 3 != 0)
{
string stuff =new String(' ',3 - sBuffer.Length % 3);
sBuffer = String.Concat(sBuffer, stuff);
}
int j = sBuffer.Length;
for (int i = 1; i <= j; i += 3)
{
str1 = String.Concat(str1, Convert.ToString( (char)( (int)Convert.ToChar(sBuffer.Substring( i-1, 1)) / 4 + 32)));
str1 = String.Concat(str1, Convert.ToString((char)((int)Convert.ToChar(sBuffer.Substring( i-1, 1)) % 4 * 16 + (int)Convert.ToChar(sBuffer.Substring ( i , 1)) / 16 + 32)));
str1 = String.Concat(str1, Convert.ToString((char)((int)Convert.ToChar( sBuffer.Substring ( i , 1)) % 16 * 4 + (int)Convert.ToChar(sBuffer.Substring ( i + 1, 1)) / 64 + 32)));
str1 = String.Concat(str1, Convert.ToString((char)((int)Convert.ToChar( sBuffer.Substring ( i + 1, 1)) % 64 + 32)));
}
return str1;
}
}
}

Hide show and select tabs in CRM 4.0

How to hide, show and select tabs in CRM 4.0 If you already worked with Microsoft Dyamics CRM 4.0, you know that almost everything you do with JavaScript is considered a "hack" because you manipulate the DOM of the pages by yourself. Because of this I decided to give you some help with differents helper methods I developped at my day job. I'm currently working on a big development project involving CRM.

Hide a tab in CRM 4.0

 
/* Jscript: Hide a tab in CRM 4.0 */




function HideTab(tabNumber)
{
var tab = document.getElementById("tab" + (tabNumber - 1).toString() + "Tab");
tab.style.display = "none";
}

Show a tab in CRM 4.0

 
/* Jscript: Show a tab in CRM 4.0 */
function ShowTab(tabNumber)
{
var tab = document.getElementById("tab" + (tabNumber - 1).toString() + "Tab");
tab.style.display = "";
}

Select a tab in CRM 4.0

 
/* Jscript: Select a tab in CRM 4.0 */
function SelectTab(tabNumber)
{
var tab = document.getElementById("tab" + (tabNumber - 1).toString() + "Tab");
tab.click();
}

LookupProperty in a plugin

 

This is the code to create a lookup property for my custom entity

Lookup salesPersonLookup = new Lookup(“new_salesperson”, crmkey.Value);
LookupProperty lookupProperty = new LookupProperty(“new_salespersonid”, salesPersonLookup);

first you need to create a lookup, this has the syntax of

new Lookup(“entity name”, guid of entity to lookup) 

then you need to add the lookup into a LookupProperty

new LookupProperty(“field name”, Lookup) 

You then add this property to your property bag and you will be able to update that property