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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Send notes attachment via email using Plugin

(0) ShareShare
ReportReport
Posted on by 3,634

I have following snippet to get the attached document of notes of an Order. Now, I want to attach this document in a email using plugin. Any idea/suggestion to attach this document to email attachment.

	EntityCollection results = null;
	QueryExpression query = new QueryExpression
    {
		EntityName = "annotation",
		ColumnSet = new ColumnSet("subject", "filename", "notetext", "documentbody"),
		Criteria = new FilterExpression
		{
			Conditions = {
		new ConditionExpression {
			AttributeName ="objectid",
			Operator = ConditionOperator.Equal,
			Values = { order }
		},
		new ConditionExpression {
			AttributeName = "isdocument",
			Operator = ConditionOperator.Equal,
			Values = { true}
		}
			}
		}
    };

    results = service.RetrieveMultiple(query);


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi  Mohsin,

    You need to create an ActivityMimeAttachment and set the body to the documentbody of the note - there is a sample in the SDK - msdn.microsoft.com/.../gg328344.aspx

    Hope this answers your question!

  • Inogic Profile Picture
    709 on at

    Hi Mohsin,


    You can use following code to create email attachment

    Entity attachement = new Entity("activitymimeattachment");
    //Here notesbody is text of notes
    attachement["body"] = notesBody;
    tracingService.Trace("body");

    attachement["filename"] = "mime-attachment.txt";
    tracingService.Trace("file");

    attachement["objectid"] = new EntityReference("email", emailId);
    tracingService.Trace("object id");

    attachement["objecttypecode"] = "email";
    tracingService.Trace("type code");

    attachement["subject"] = subjectData;
    tracingService.Trace("subject");

    attachement["mimetype"] = "text/calendar";
    tracingService.Trace(“Before creating Attachment”);

    service.Create(attachement);

    tracingService.Trace("Attachment created");

    You can also refer the below link:
    https://rajeevpentyala.com/tag/activitymimeattachment/ 

    Hope this helps!

    Thanks!

    Sam

  • Suggested answer
    Community Member Profile Picture
    on at

    please find the detailed steps for your req: community.dynamics.com/.../sending-email-with-entity-attachment-from-notes

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans