web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error on creating new Email(custom Workflow)

(0) ShareShare
ReportReport
Posted on by 224

Hi Guys

I need some help about this error everytime i created new email 

OtherID.png

can anyone help me on how to fix this?

Thank you so much for the help

*This post is locked for comments

I have the same question (0)
  • Kokulan Profile Picture
    18,054 on at

    Hi KaeL

    You could be getting the above error for couple of reasons and it would be easy if I could have a look at the plugin code that fails but following could possibly be why you are getting the error.

    The error you are getting is from the plugin that triggers on Pre-Create of email.

    In the plugin code, it seems to be expecting an value in a dictionary possibly looking for an attribute in the entity image (context.InputParameters["Target"]).

    Normally, when a record is retrieved, if a field does not have a value, the field wont be int he collection and it could be whey its complaining about the key not being present int he dictionary.

    If you have access to code, you could check the plugin code to see what dictionary and value its trying to access.

    Hope it helps.

  • AllanDeCastro Profile Picture
    156 on at

    This exception is thrown when you try to index to something that isn't there. For example, you try to use field from the Target entity which are not presents. Or  it could be an error when you'are trying to set a value of an entity's field who doesnt exist.

    As said in the previous comment, try to send your code and I will be able to make a review about it.

    While waiting for your reply, I just want to tell you that you have to use the entity.Contains("FIELD_NAME") before trying to get  or set him!

  • Suggested answer
    Adrian Begovich Profile Picture
    1,032 Moderator on at

    Hi KaeL,

    A problem with EmailCreatePre causes an exception. If you post your code, we will be able to pinpoint the issue.

  • KaeL Profile Picture
    224 on at

       private static void CreateEmail()

           {

               Uri organizationUri = new Uri("crm/.../Organization.svc");

               IServiceConfiguration<IOrganizationService> organizationConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUri);

               ClientCredentials credentials = new ClientCredentials();

               credentials.Windows.ClientCredential.Domain = "CRM";

               credentials.Windows.ClientCredential.UserName = "Administrator";    

               credentials.Windows.ClientCredential.Password = "Password123";

               using (OrganizationServiceProxy proxy = new OrganizationServiceProxy(organizationConfigInfo, credentials))

               {

                   proxy.EnableProxyTypes();

                   Email email = new Email

                   {

                       Subject = "Test Email Subject",

                       ActivityId = Guid.NewGuid()

                   };

                   emailID = proxy.Create(email);

                   Console.WriteLine("email created");

               }

           }

  • KaeL Profile Picture
    224 on at

    I want to try first to test this on a console application and i tried the code from this link  and my goal is i want to attach the attachment to email i can able to retrieve the attachment from a custom entity that we stored all of the attachment using the annotation entity. but everytime i tried to make a email record i got this error even on the console application and also i tried on the crm.5025.2.PNG

    5025.2.PNG

  • KaeL Profile Picture
    224 on at

    and i did another custom workflow from here www.oak3.org/.../attach-note-attachments-emails and still i got the same error.

  • KaeL Profile Picture
    224 on at

    from this link for creating email docs.microsoft.com/.../sample-create-retrieve-update-delete-email-attachment

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Kael,

    Go yo Setting》Customization 》Customize My System 》 On a popup, left side nav8gatiob, click on Sdk Message Processing steps.

    The above will show you all the plugin steps you have in your system. From here you need to identiy the plugin running on create of email...note them down and the disable. Test your vode again, if it works you need to review the disabled plugin code.

    Basically the error is not coming from rhe code which creates email but the plugin which teiggers when the email is created...so your code is creating email which is triggere pre create email plugin and that plugin is failing with the error.

    《sorry for any typos, i am usimh my phone keypad》

    Hope this help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans