Programming Tips

Programming
Flash Programming
Programming on Mobile
Software Development
3D Programming
Programming Tips
How to Program
Computer Programming
Programming Languages
CROSS PLATFORM MOBILE DEVELOPMENT

Programming Tips

Sponsored Ad
CROSS PLATFORM MOBILE DEVELOPMENT
Programming Tips Microsoft CRM Customization ? programming email activity attachment


Microsoft CRM is now on the scene and it is increasing its market share, due to Microsoft Business Solutions muscles and market strategy. It is tightly integrated with other Microsoft Maker Solutions products such equal Microsoft Great Plains, Solomon, Navision. Being relatively inexpensive in comparison to competitors, desire Siebel, Oracle - Microsoft CRM opens you the door for worldwide plural automatize. In this small article we would like to give you, software developer, some hints on Microsoft CRM customization.

Today's topic is Activity of email nature programming - you usually deal with these customizations when you improve Microsoft Exchange CRM temporary hookup. How actor you create junk e-mail law - this is the main discussion topic. We?ll use C#.Net.

In Exchange handler/event sink in you create Inactiveness of email type in MS CRM and one of the tasks is transfer the attachment(s) from the body of the incoming email to the attachment(s) in the Activity. You can realize it through direct access to Microsoft CRM DB. Let?s see C# code:

1. First we are getting access to the letter via ExOLEDB:


CDO.Message iMessage = new CDO.MessageClass();

CDO.IBodyPart iPrt;


iMessage.DataSource.Open(bstrURLItem, null, ADODB.ConnectModeEnum.adModeRead,


ADODB.RecordCreateOptionsEnum.adFailIfNotExists, ADODB.RecordOpenOptionsEnum.adOpenSource, "", "");


2. Next ? we come through the judicial writ list, get their traducement and save their bodies into impermanency catalogue:


for(int i = 1; i ";

strXml += "Activity 1";

strXml += "" + attachmentNumber + "";

strXml += "" + emailId.ToString("B") + "";

strXml += "";


// Create the activity attachment

Guid attachmentId = new Guid(activityAttachment.Create(userAuth, strXml));

log.Debug("Create Attachemnt ID: " + attachmentId.ToString("B"));


UploadFileToDB(attachmentId, filename, filesize);


return attachmentId;

}

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. Main problem, however is attachment body part adding to MS CRM database. Main requirement is ? attachment must be encoded as BASE64 stream and its light time must be specified correctly together with Nine Type and file name of the record it will be knows as an connection in activity. Let?s look at the C# code:


public shitter UploadFileToDB(Guid attachmentId, string filename, long filesize) {

string contentType =


"application/octet-stream";


try {

Hashtable mimes = LoadMimeDB(Environment.SystemDirectory + "/Albaspectrum/ContentType.txt");


if (mimes != null) {

string tmpContentType = GetMimeType(mimes, filename);


if (tmpContentType != sweet fanny adams && !tmpContentType.Equals(""))

contentType = tmpContentType;

}


byte[] memoryData = new byte[filesize];


FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);

BinaryReader reader = new BinaryReader(fs);


reader.Read(memoryData, cipher, (int)filesize);


reader.Close();

fs.Close();


OleDbCommand command = conn.CreateCommand();


command.CommandText = "UPDATE ActivityMimeAttachment SET FileSize = (?), MimeType = (?), FileName = (?), Body = (?) WHERE ActivityMimeAttachmentId = (?)";

command.Prepare();

command.Parameters.Add(new OleDbParameter("FileSize", filesize));

command.Parameters.Add(new OleDbParameter("MimeType", contentType));

command.Parameters.Add(new OleDbParameter("FileName", new FileInfo(filename).Name));

command.Parameters.Add(new OleDbParameter("Body", Convert.ToBase64String(memoryData, 0, (int)filesize)));

command.Parameters.Add(new OleDbParameter("ActivityMimeAttachmentId", attachmentId));


log.Debug("Prepare to upload attachemnt " + attachmentId.ToString("B") + " in ActivityMimeAttachment");


command.ExecuteNonQuery();


memoryData = null;

}

catch (Exception e) {

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

}

}


6. File ContectType.txt is matching list of the files extensions and their mime-type in the following format:


asc application/pgp-encrypted Armored Encrypted file (PGP)

asd application/astound Autosave file (Word for Windows)

asm PC ASM File

asn application/astound


etc.

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

Boris Makushkin is Lead Software Short-stop 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, Metropolis, Toronto, Vancouver, Moscow and Europe and internationally (www.albaspectrum.com), he is Microsoft CRM SDK, C#, VB.Net, SQL, Oracle, Unix developer.


borism@albaspectrum.com



transparent
Computer Repair Hoffman Estates  Computer Repair Downtown  Computer Repair Itasca  Computer Repair St Charles  Computer Repair Wayne  
SOFTWARE DEVELOPMENT CHICAGO  C SHARP PROGRAMMING  COMPUTER PROGRAMMER  BUSINESS PROGRAMMING CHICAGO  COMPUTER PROGRAMMING  FLEX DEVELOPMENT  CUSTOM SOFTWARE DEVELOPMENT CHICAGO  PROGRAMMING CHICAGO  LIGHTSWITCH DEVELOPMENT  
ASSISTED LIVING  FLEX DEVELOPMENT  Bathroom  CUSTOM SOFTWARE DEVELOPMENT CHICAGO  REPUBLICANS  INFORMATION  WEB SITE HOSTING   ...  
~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~   PROG