Activity Guide
 
HOME | CONTACT US | SITE MAP

Recent Searches:
Search: Activity
Search: Athletics
Search: Workout Gear

Partner Sites:
Web Inceptions, Inc.
Domain Name Sales
Domain Registration Alerts


New Sites:
Supernatural Photography
Bargain Scrapbooks
Challenge Workshop
Virtual Pets
Reconcilable Differences
The Love Bible
Advanced Navigation
PUA
Hyper Seduction
Advanced Defense
Party Confidential
Spice Chefs
Adventure Climbers
Independent Cycling
Organic Parenting
Affordable Beach Living
Coach Promotion
Nightlife Photographer
Affordable Home Broker
Interior Updates
Real Estate Bailout
Serenity Photography
Advanced Exports
Enhanced Photography
Smart Custody
Adventure By Nature
The Wine You Love
Bridal Insight
Inspirational Instruction
Coral Adventures
ActivityGuide.info
Tuesday, March 09, 2010


Microsoft CRM Customization: programming Closed Email Activity

Microsoft CRM Customization – programming Closed Email Activity by: Boris Makushkin

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 + "\r\n" + 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 + "\r\n" + 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 + "\r\n" + e. StackTrace);

}

}

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

Author:
Boris Makushkin

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 borism(at)albaspectrum.com.borism(at)albaspectrum.com



More great sites:
Law Without Lawyers | Lawyer Tools | Legal Mediator | Legal Professionals | Legal Tax Secrets | Lifetime Beauty | Listing Broker | Love Chemistry | Office Available | Own Hawaii | Patent Compliance | Patent Litigators | Perfect Union | Personal Bankruptcy Law | Personal Workout | Pregnancy Doctor | Property Improvements | Property Renovations | Protect My Home | Realty Baja | Realty Consultant | Realty Expert | Realty Financing | Realty Foreclosure | Realty For Sale By Owner | Realty London | Realty Rights | Reduce Property Taxes | Reit Homes | Relationship Wisdom | Reo Foreclosures | Reo Investor | Reposessed Property | Resort Timeshare | Retirement Investments | Safety Review | Senior Nursing Care | Singles Market | Sports Attorney | Tax Clinic | Tax Protection | Timeshare Resort | Trial Expert | Visa Lawyer | Wireless Marketplace | Discount Photography | Event Photography | Business Promotion | Cheap Medicine | Credit Review | Debutant | Defer | Estuary | Family Bible | Family Law Mediators | Lawyer Studio | Leash Law | Legal Mediation | Love Training | Mobile Lawyer | Mobility Systems | Muscle Injury | Natural Drugs | Necropsy | Ocean Boulevard | Osmoses | Personal Calendar | Personal Rights | Personnel Office | Political Debate | Precertified | Prefinancing | Presurgery | Property For Sale By Owner | Property Liquidation | Publicity For Lawyers | Rehearsed | Rehiring | Relationship Counseling | Web Advocates |

Do you have a web site? Please link to us!


ActivityGuide.info: Microsoft CRM Customization: programming Closed Email Activity

More Activity information:

Article: Law School Torts II Course Outline Law School Torts II Course Outline

Article: Pointless Targets Pointless Targets

Article: Mental vs Physical Activity in Marketing Mental vs Physical Activity in Marketing

Article: Microsoft CRM Customization: programming Closed Email Activity Microsoft CRM Customization: programming Closed Email Activity

Article: Exercise For Any Size Exercise For Any Size

Article: Burn Fat  24 Hours a Day - Increase Your Metabolic Rate Burn Fat 24 Hours a Day - Increase Your Metabolic Rate

Article: Ready?Set?Go! Transition Strategies for Caregivers Ready?Set?Go! Transition Strategies for Caregivers

Article: Physical Activity and Less? Physical Activity and Less?

Article: Influences On Whitetail Deer Activity Influences On Whitetail Deer Activity

Article: Playing Games Does Not Help Your Weight Loss Efforts Playing Games Does Not Help Your Weight Loss Efforts

Article: Peak Performance? What You See Is What You Get! Peak Performance? What You See Is What You Get!

Article: A Blowing Bubble Activity that will Blow the Kids Away A Blowing Bubble Activity that will Blow the Kids Away

Article: Home Spa and Bodys Adaptation. The More the Better? Home Spa and Bodys Adaptation. The More the Better?

Article: Microsoft CRM Customization: programming email activity attachment Microsoft CRM Customization: programming email activity attachment

Article: Wheres the Water? Wheres the Water?

Article: Vitamin Tips To Fuel Physical Activity Vitamin Tips To Fuel Physical Activity

Article: Dieting? Mental Activity is as Important as Physical Dieting? Mental Activity is as Important as Physical

Article: Incorporating Physical Activity into Your Daily Routine Incorporating Physical Activity into Your Daily Routine

Article: Microsoft CRM Customization? Programming Closed Email Activity Microsoft CRM Customization? Programming Closed Email Activity

Article: Develop Your Childs Genius - Right Brain/Left Brain Coordination Develop Your Childs Genius - Right Brain/Left Brain Coordination

Article: Microsoft CRM Customization secrets: second edition Microsoft CRM Customization secrets: second edition

Article: Beware of the Newest Activity Online Phishing Beware of the Newest Activity Online Phishing

Article: Great Activities and Adventures in Kauai Great Activities and Adventures in Kauai

Article: How Many Calories Are Too Many How Many Calories Are Too Many

Article: Why they are mistaken about Aerobic Activities Why they are mistaken about Aerobic Activities


Activity
Athletics Workout Gear

Related Items:
Travel
Sports
Activity Ride
Activity
Technology
Fitness
Camping
Crafts
Hiking
Adventure Travel
Self Tanning
Walkthroughs
Psychonauts
Activity Options
Stanford Sports
Stanford Athletics
Animal Activities
Dartmouth Sports
Health Word
Ole Miss Athletics
Marquette University Athletics
Harwood Auto
Wisconsinopoly
Cub Scout Outdoor Activity Award
Operation
California Missions
North Carolina Football
Dartmouth Football
Buddy Teevens
Viking Athletics
Halloween School
Have Fun With Math
Michiganopoly
Purdueopoly
Metal Gear Solid 2 Strategy Guide
Stanford Football
Stanford Basketball
Music Activity
Penn State Basketball
Lacrosse Photos
Mississippi Football
Social Studies Activity
Dukeopoly
Texasopoly
Step
Aurora University
Enter The Matrix Xbox
Enter The Matrix Game
Spanish Activity
Brazil Volleyball
Penn Stateopoly
Teaching Reading In Social Studies
References
Doom 3
Strategy Guide
Auburnopoly
Pocket Guide
Math Resources
Womens Lacrosse
Math Products
Wow Game Guide
Worship
Comprehension Activities
Mechassault
Science Lesson Plans
Help
Education
Jobs
School
Job
Training
Careers
Schools
Teaching
Leadership
Yoga
Travel Guides
Find A Job
Workout
Tanning
Pilates
Aerobics
Emergency Preparedness
Meditations
Pc Game
Toning
Whiplash
Kickboxing
Safety Training
Trailblazer
Weight Training
Strategy Game
Financial Help
Timekeeping
Search People
Activity Books
Fishfinder
Security Product
Search For People
Time Recording
Meditation Techniques
Math Activities
Job Career
Vin Search
Indoor Cycling
Fish Finders
Sun Tanning
Ait 2
Reading Activities
Education Careers
Workout Wear
Ait 3
Workout Gear
Total Body Workout
Fitness Gear
Math Tools
Gym Shorts
Fitness Clothing
Athletic Clothing
Web Host Reviews
Data Security Software
Campaign Buttons
Teaching Geography
Mortgage Faq
Exercise Clothing
Exercise Clothes
30 Minute Workout
Gym Gear
Volleyball Tour
Basketball Dvd
Deb

 
Copyright © 2000-2006 ActivityGuide.info. All Rights Reserved.
Home | Contact Us | About Us | Site Map | Add URL