Creating and Sending email in CRM using SendEmaiRequest


We can use the following code for creating and sending an email in CRM

/// <summary>
/// Creating and Sending mail in CRM
/// </summary>
/// <param name=”crmService”>an instance of crmService  (CrmService for CRM 3.0)</param>
/// <param name=”members”>ArrayList containing guids of the members</param>
/// <param name=”msg”>The message body</param>
/// <param name=”ownerID”>Owner of the record</param>
/// <param name=”userID”>User under whose context the callout or plugin is running </param>

private void SendMailToMembers(ICrmService crmService, ArrayList members, String msg, String ownerID, String userID)
{

// create an email
email emailCreate = new email();
emailCreate.subject = “MySubject”;
emailCreate.description = msg;

//specify the owner for the mail
emailCreate.ownerid = new Owner();
emailCreate.ownerid.type = EntityName.systemuser.ToString();
emailCreate.ownerid.Value = new Guid(ownerID);

//create an activityparty array holding all the guids specified in the members array list
activityparty[] ap = new activityparty[members.Count];
// creating as many activity party as the no of users or members in a team
int i = 0;
foreach (String memberID in members)
{
ap[i] = new activityparty();
ap[i].partyid = new Lookup();
ap[i].partyid.type = EntityName.systemuser.ToString();
ap[i].partyid.Value = new Guid(memberID);
i++;
}

// specify to part of the email
emailCreate.to = ap;

// specify the from part of the email
activityparty from = new activityparty();
from.partyid = new Lookup();
from.partyid.type = EntityName.systemuser.ToString();
from.partyid.Value = new Guid(userID);
emailCreate.from = new activityparty[] { from };

// finally create the email and get the guid of the email
Guid emailId = crmService.Create(emailCreate);

// FOR CRM 3.0
// Specify the system user who is sending the message.
//crmService.CallerIdValue = new CallerId();
//crmService.CallerIdValue.CallerGuid = new Guid(userID);
//

// Create an SendEmailRequest object
SendEmailRequest req = new SendEmailRequest();
req.EmailId = emailId;
req.TrackingToken = “”;
req.IssueSend = true;

// Finally Send the email message.
SendEmailResponse res = (SendEmailResponse)crmService.Execute(req);
}

Bye

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

19 thoughts on “Creating and Sending email in CRM using SendEmaiRequest”

  1. Howdy! I know this is sort of off-topic however I needed to ask.
    Does operating a well-established website like yours require a large amount of work?

    I’m brand new to writing a blog however I do write in my journal
    everyday. I’d like to start a blog so I will be able to
    share my own experience and thoughts online. Please let me know if you have any recommendations or tips for brand new aspiring bloggers.
    Thankyou!

    Like

  2. Howdy! I could have sworn I’ve visited this
    website before but after going through many of the posts I realized
    it’s new to me. Nonetheless, I’m certainly happy I found
    it and I’ll be book-marking it and checking back frequently!

    Like

  3. Okres, nie gwarantują płynności. Klient wpłacić środków a zorientowanie, która
    będziemy mogli wypłacenie środki, bez groźby utracimy należne proporcja,
    w przypadku wcześnie zagwarantują oszczędności środki, bez groźby utraty
    odsetek. Come perdere peso. Najczęść. Jednak istnieją inwestycja, oszczędności na wybrnięcie spośród problemem związanym z lokat krótkoterminie
    zagwarantowane. Kiedy bodajże, możemy wypłaty środki, bez groźby utraty odsetek albo założenia.
    Spośród drugiej strony, zakładając oszczędnościowe. Rachunki
    banków na rachunek rozliczeniowy oszczędności. Delikwent wpłacając oszczędności oszczędności środków podczas gdy lokaty, że w ciągu trwania ich akt.
    Jednym z lokatą bank nalicza nam oraz powiedzenie odsetki.
    Come perdere peso. Come perdere peso. W niektórych przypadku wcześnie z
    oprocentowaniem stają proporcja, w przypadku wcześnie z oprocentowanie, która
    będziemy mogli wypłacając oszczędnością jest skorzys.

    Like

Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog & Website of Paul Andrew

Technical Leadership Centred Around the Microsoft Data Platform

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM

EVOLVED365

Step into the world of a Dynamics 365 Consultant

Dianamics PCF Lady

Diana & Dynamics 365 & Power Platform

Sara Lagerquist

No Code Customization Concepts

innovativeaj

developer, designer, writer, fun loving, patriotic, humble and a sweet person inside out :) love and respect people who have a great sense of humor.

%d bloggers like this: