Saturday, November 28, 2020

MSCRM Email Plugins C# with and Without CRM Reference

 // Create a new activity party linked to a contact

Entity party1 = new Entity("activityparty"); party1["addressused"] = "some@email.com"; party1["partyid"] = new EntityReference("contact", contactId); // Create a new unresolved activity party Entity party2 = new Entity("activityparty"); party2["addressused"] = "unresolved@email.com"; // Create a new EntityCollection and add the 2 parties EntityCollection to = new EntityCollection(); to.Entities.Add(party1); to.Entities.Add(party2); // Create an email with the EntityCollection Entity email = new Entity("email"); email["subject"] = "Test Party Lists"; email["to"] = to; Guid _emailid = service.Create(email);

    if (_emailid != Guid.Empty)
    {
        SendEmailRequest sendEmailreq = new SendEmailRequest
        {
            EmailId = _emailid,
            TrackingToken = "",
            IssueSend = true
        };

        SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);
    }

Monday, November 2, 2020

Mscrm Attachment with Seperate Folder

 string root = @"D:\Business";

                    // If directory does not exist, create it. 

                    if (!Directory.Exists(root))

                    {

                        Directory.CreateDirectory(root);

                    }


string FilePath = @"D:\Business\" + loopFetchIndApplications.Attributes["new_businessapplicationid"].ToString();

                                    // Create a sub directory

                                    if (!Directory.Exists(FilePath))

                                    {

                                        Directory.CreateDirectory(FilePath);

                                    }

                                    string getAttachments = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>

   <entity name='annotation'>

                                                     <attribute name='subject' />

                                                    <attribute name='notetext' />

                                                    <attribute name='filename' />

                                                    <attribute name='documentbody' />

                                                    <attribute name='mimetype' />

                                                    <attribute name='annotationid' />

    <order attribute='subject' descending='false' />

  </entity>

</fetch>";



                                    getAttachments = getAttachments.Replace("{replaceID}", loopfetchgetIndDocuments.Id.ToString());


                                    EntityCollection fetchAnnotations = service.RetrieveMultiple(new FetchExpression(getAttachments));


                                    foreach (var loopfetchAnnotations in fetchAnnotations.Entities)

                                    {

                                        if (loopfetchAnnotations.Attributes.Contains("documentbody"))

                                        {

                                            //Also check here, if file with the same name already exists, if not create one

                                            if (!String.IsNullOrWhiteSpace(loopfetchAnnotations.Attributes["documentbody"].ToString()) && !File.Exists(FilePath + "\\" + loopfetchAnnotations.Attributes["filename"].ToString()))

                                            {

                                                byte[] data = Convert.FromBase64String(loopfetchAnnotations.Attributes["documentbody"].ToString());

                                                File.WriteAllBytes(FilePath + "\\" + loopfetchAnnotations.Attributes["filename"].ToString(), data);

                                            }

                                        }

                                    }


                                }

How to Clear Cache in Canvas PowerApps while working on Offline mode?

  Introduction In this blog, we’ll look at how to clear cache in Canvas Apps when using the Power Apps mobile application, especially when t...